- UID
- 1
- 积分
- 16111
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-1-3
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
LISP: Problem using :vlr-pickfirstmodified reactor
Issue
Calling (entget) in my :vlr-pickfirstmodified callback causes AutoCAD to crash.
To reproduce this, load the Lisp code below, and then select a PViewport in a layout:
(vl-load-com)
(vl-load-reactors)
(vlr-miscellaneous-reactor nil (list (cons ':vlr-pickfirstmodified 'crash)))
(defun Crash (p1 p2 / sel ii)
(setq sel (cadr (ssgetfirst))
ii 0
)
(repeat (if sel (sslength sel) 0)
(setq ent (ssname sel ii)
ii (1+ ii)
)
(entget ent)
)
)
Solution
The reactor works fine when SDI= 1. However, in a multiple-document environment (SDI=0), the problem arises. Most likely, the entity can not be opened for write in your editor reactor (:vlr-miscellaneous-reactor is an editor reactor), because the document is not locked. In an editor reactor, in MDI (SDI=0), the document is not automatically locked. It is not possible to lock the document in Visual LISP, however it is possible in ObjectARX. Thus, we can call ObjectARX functions from the Lisp code to work around the problem.
In the example below, we use ObjectARX (acedDefun) to define two functions, (lockdoc) and (unlockdoc), which can be called from the Lisp code:
|
|