- 积分
- 24557
- 明经币
- 个
- 注册时间
- 2004-3-17
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2010-11-20 16:04:00
|
显示全部楼层
本帖最后由 作者 于 2010-11-20 21:52:29 编辑
InvokeArx.cs+-
- [DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl)]
- private static extern int acdbEntLast(long[] name);
- public static bool EntLast(out long[] name)
- {
- name = new long[2];
- int errStatus = acdbEntLast(name);
- return errStatus == 5100;
- }
- [DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl)]
- private static extern int acdbEntNext(long[] name, long[] next);
- public static bool EntNext(long[] name, out long[] next)
- {
- next = new long[2];
- int errStatus = acdbEntNext(name, next);
- return errStatus == 5100;
- }
- [DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl)]
- private static extern IntPtr acdbEntGet(long[] name);
- public static ResultBuffer EntGet(long[] name)
- {
- IntPtr ip = acdbEntGet(name);
- if(ip != IntPtr.Zero)
- return ResultBuffer.Create(ip, false);
- return null;
- }
- [DllImport("acdb17.dll", CallingConvention = CallingConvention.Cdecl)]
- private static extern ErrorStatus acdbGetObjectId(ref ObjectId id, long[] name);
- public static ObjectId GetObjectId(long[] name)
- {
- ObjectId id = ObjectId.Null;
- ErrorStatus errStatus = acdbGetObjectId(ref id, name);
- return id;
- }
调用:-
- [CommandMethod("tt6")]
- public static void test26()
- {
- Document doc = Application.DocumentManager.MdiActiveDocument;
- Editor ed = doc.Editor;
- Database db = doc.Database;
- long[] name;
- InvokeArx.EntLast(out name);
- ed.WriteMessage("\n" + name[0].ToString());
- InvokeArx.Command(false, "line", Point3d.Origin, new Point3d(10, 10, 0));
- long[] next;
- InvokeArx.EntNext(name, out next);
- ed.WriteMessage("\n" + next[0].ToString());
- ResultBuffer rb = InvokeArx.EntGet(next);
- ed.WriteMessage("\n" + rb.ToString());
- var id = InvokeArx.GetObjectId(next);
- ed.WriteMessage("\n" + id.ToString());
- using (Transaction tr = db.TransactionManager.StartTransaction())
- {
- Line l = tr.GetObject(id, OpenMode.ForWrite) as Line;
- l.ColorIndex = 2;
- tr.Commit();
- }
- }
先在图里画一个图元
命令: tt6
9033026376985834376指定第一点: _non
指定下一点或 [放弃(U)]: _non
指定下一点或 [放弃(U)]:
命令:
9033026480065049488
((-1,(2130277264))(0,LINE)(330,(2130271480))(5,1B2)(100,AcDbEntity)(67,0)(410,Mo
del)(8,0)(100,AcDbLine)(10,(0,0,0))(11,(10,10,0))(210,(0,0,1)))
(2130277264)
|
|