显示CAD实体的objectID

 

(vl-load-com)

(defun c:ObjectID()    ;; This example creates several objects in model space.    ;; It then iterates through model space and displays the    ;; ObjectID for each object found.    (setq acadObj (vlax-get-acad-object))    (setq doc (vla-get-ActiveDocument acadObj))    (setq modelSpace (vla-get-ModelSpace doc))    ;; Create a Ray object in model space    (setq basePoint (vlax-3d-point 3 3 0)          secondPoint (vlax-3d-point 1 3 0))    (setq rayObj (vla-AddRay modelSpace basePoint SecondPoint))    ;; Create a Polyline object in model space    (setq points (vlax-make-safearray vlax-vbDouble '(0 . 5)))    (vlax-safearray-fill points '(3 7                                  9 2          3 5         )    )    (s
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
在 AutoCAD C# 中实现撤销(Undo)实体的操作,可以使用 `Transaction` 类来创建一个事务,然后在事务中执行实体的操作,以便可以通过 `TransactionManager.Undo()` 方法来撤销这些操作。以下是一个示例代码: ```csharp // 获取 AutoCAD 当前文档的数据库对象 Database db = Application.DocumentManager.MdiActiveDocument.Database; // 开始一个新事务 using (Transaction tr = db.TransactionManager.StartTransaction()) { try { // 选择实体 Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; PromptEntityOptions peo = new PromptEntityOptions("\n选择实体:"); PromptEntityResult per = ed.GetEntity(peo); if (per.Status != PromptStatus.OK) { return; } Entity ent = (Entity)tr.GetObject(per.ObjectId, OpenMode.ForWrite); // 在事务中修改实体 // ... // 提交事务 tr.Commit(); // 撤销事务 db.TransactionManager.QueueForUndo(tr); } catch (Autodesk.AutoCAD.Runtime.Exception ex) { // 处理异常 ed.WriteMessage("\n" + ex.Message); tr.Abort(); } } ``` 在上面的示例中,我们首先选择了一个实体,然后在事务中修改了该实体。在提交事务之后,我们将事务添加到撤销队列中,以便可以通过 `TransactionManager.Undo()` 方法来撤销该事务。注意,我们使用了 `QueueForUndo()` 方法来将事务添加到撤销队列中,而不是直接调用 `Undo()` 方法,这是因为在事务中可能会有多个实体的操作,而我们只想撤销这些操作中的某一个。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

lisp宏

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值