- (defun c:unblock(/ doc mspace objs pt pt blkdef)
- (vl-load-com)
- (setq doc (vla-get-activedocument (vlax-get-acad-object))
- mspace (vla-get-modelspace doc)
- ss (ssget)
- objs (selectionset->vla-object-list ss)
- pt (getpoint "\n选择插入点:")
- blkdef (blk:make-block pt "*U" objs doc))
- (mapcar 'vla-delete objs)
- (vla-insertblock mspace (vlax-3d-point pt) (vla-get-name blkdef) 1 1 1 0)
- (mapcar 'vlax-release-object (list doc mspace blkdef))
- (princ)
- )
-
- ;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)))
- )
- )
- )
- )
- )
- )
- ;;;
|