马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
问题:
How to perform a bind-as-insert an Xref, using Visual LISP?
解答:
In AutoCAD , the BINDTYPE system variable was introduced. By setting it
to 1, a bind-as-insert is performed:
(setvar "BINDTYPE" 1)
(command "_-xref" "_bind" "MYBLOCK")
(setvar "BINDTYPE" 0)
Using Visual Lisp, the following code will accomplish the same task in AutoCAD
. See below:
- (defun c:BindInsert ( / appAcad docActive colBlocks objBlk)
- (vl-load-com) ;load ActiveX
- (setq appAcad (vlax-get-acad-object)
- docActive (vla-get-ActiveDocument appAcad)
- ) ;setq
- ;;get the blocks collection
- (setq colBlocks (vla-get-blocks docActive))
- (vlax-for objBlk colBlocks
- ;;Is the block an xref?
- (if (= (vlax-get-property objBlk 'IsXref) :vlax-true)
- ;;if True, then bind it as an insert
- (vlax-invoke-method objBlk "bind" :vlax-true)
- ) ;if
- (vlax-release-object objBlk)
- ) ;vlax-for
- ;;release objects from memory
- (vlax-release-object colBlocks)
- (vlax-release-object docActive)
- )
-
Note: In AutoCAD 2000/2000i, there is a problem with the Bind method. The results
are opposite (i.e. invoking the Bind method with :vlax-true does not bind the
xref as an insert). In that case, the workaround is to change the argument
to :vlax-false. This is not a problem in AutoCAD 2002.
|