This function can be used in next ways:
1) Redraw screen
2) Show/hide entity -> Entity.Visible = true (or false)
3) Highlight/Unhighlight entity -> Entity.Highlight(..)/Entity.Unhighlight(...)
#define ACADR16
using System ;
using System.Runtime.InteropServices ;
using Autodesk.AutoCAD.Runtime ;
using Autodesk.AutoCAD.ApplicationServices ;
using Autodesk.AutoCAD.EditorInput ;
using Autodesk.AutoCAD.DatabaseServices ;
using Autodesk.AutoCAD.Geometry ;
[assembly: CommandClass(typeof(Rivilis.Redraw))]
namespace Rivilis
{
public class Redraw
{
[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl)]
private static extern Int32 acedRedraw(long [] name, Int32 mode);
#if ACADR16
[DllImport("acdb16.dll", CallingConvention=CallingConvention.Cdecl, EntryPoint="?acdbGetAdsName@@YA?AW4ErrorStatus@Acad@@AAY01JVAcDbObjectId@@@Z")]
#elif ACADR17
[DllImport("acdb17.dll", CallingConvention=CallingConvention.Cdecl, EntryPoint="?acdbGetAdsName@@YA?AW4ErrorStatus@Acad@@AAY01JVAcDbObjectId@@@Z")]
#endif
private static extern int acdbGetAdsName(long [] name, ObjectId objId);
[CommandMethod("MyRedraw")]
static public void MyRedraw()
{
acedRedraw(null, 1);
}
// Highlight entity
[CommandMethod("HlEnt")]
static public void HlEnt()
{
PromptEntityOptions entityOpts = new PromptEntityOptions("\nSelect entity: ");
PromptEntityResult rc = Application.DocumentManager.MdiActiveDocument.Editor.GetEntity(entityOpts);
if (rc.Status == PromptStatus.OK)
{
long [] ent = new long [] { 0, 0};
acdbGetAdsName(ent,rc.ObjectId);
acedRedraw(ent, 3);
}
}
// Unhighlight entity
[CommandMethod("UlEnt")]
static public void UlEnt()
{
PromptEntityOptions entityOpts = new PromptEntityOptions("\nSelect entity: ");
PromptEntityResult rc = Application.DocumentManager.MdiActiveDocument.Editor.GetEntity(entityOpts);
if (rc.Status == PromptStatus.OK)
{
long [] ent = new long [] { 0, 0};
acdbGetAdsName(ent,rc.ObjectId);
acedRedraw(ent, 4);
}
}
}
}