Bind-as-Insert, using Visual LISP?
问题:
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.
页:
[1]