参考这个程序
;BLK:MAKE-BLOCK_______________________________________________ ;Creates a block out of list of vla-objects ;Arguments ; 1) insertion point <(x y z)> ; 2) block name <string> ; 3) list of entities as vla-objects ; 4) document object ; 5) Use "*u" as the blockname argument to this function ; TO MAKE AN UNNAMED BLOCK
(defun blk:make-block (ip blockname vla-objects doc / blkobj sArray) (setq blkobj (vla-add (vla-get-blocks doc) (vlax-3d-point ip) blockname) sArray (vlax-safearray-fill (vlax-make-safearray vlax-vbObject (cons 0 (1- (length vla-objects))) ) vla-objects ) ) (vla-copyobjects doc sArray blkobj) blkobj ) ;;;将选择集换成对象表 (defun selectionset->vla-object-list (sset / thelist idx) (setq thelist '() idx -1 ) (repeat (sslength sset) (setq thelist (append thelist (list (vlax-ename->vla-object (ssname sset (setq idx (1+ idx))) ) ) ) ) ) ) ;;; |