- UID
- 38377
- 积分
- 135
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2003-3-25
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
调用C++的acedRedraw函数。
这个函数还是挺有用的,可以用于:
- 重新绘制屏幕
- 显示/隐藏实体后更新实体
- 高亮显示/不高亮实体显示后更新实体
对于本贴的问题,应该是第一个。但下面的代码中包含了高亮显示的内容。
- #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);
- }
- // 高亮显示实体
- [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);
- }
- }
- // 取消实体高亮显示
- [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);
- }
- }
- }
- }
请注意开头的#define ACADR16,这个表示现在的CAD版本是2006,如果你用的是2007/2008的话,请把它改成#define ACADR17
- <System.Security.SuppressUnmanagedCodeSecurity()> _
- <System.Runtime.InteropServices.DllImport("acad.exe", CallingConvention:=System.Runtime.InteropServices.CallingConvention.Cdecl)> _
- Private Shared Function acedRedraw(ByVal name As Long(), ByVal mode As Integer) As Integer
- End Function
- <CommandMethod("MyRedraw")> _
- Public Sub MyRedraw()
- acedRedraw(Nothing, 1)
- End Sub
|
|