如果您要执行其中的许多操作,为什么要手动选择每个操作?试试下面的代码..尽管您还必须考虑当前属性值。
- (defun c:bmi (/ b doc i l n o p r spc x y z)
- (vl-load-com)
- (setq doc (vla-get-activedocument (vlax-get-acad-object))
- spc (if (zerop (vla-get-activespace doc))
- (if (= (vla-get-mspace doc) :vlax-true)
- (vla-get-modelspace doc)
- (vla-get-paperspace doc)
- )
- (vla-get-modelspace doc)
- )
- )
- (while (and (setq o (car (entsel)))
- (setq o (vlax-ename->vla-object o))
- (setq i (vlax-get o 'normal))
- (> 0 (nth 2 i))
- )
- (progn (setq p (vlax-get o 'insertionpoint))
- (setq l (vlax-get o 'layer))
- (setq r (vlax-get o 'rotation))
- (setq x (- (vlax-get o 'xscalefactor)))
- (setq y (vlax-get o 'yscalefactor))
- (setq z (vlax-get o 'zscalefactor))
- (setq n (vlax-get-property
- o
- (if (vlax-property-available-p o 'effectivename)
- 'effectivename
- 'name
- )
- )
- )
- (vl-catch-all-error-p
- (setq
- b (vl-catch-all-apply (function vla-insertblock) (list spc (vlax-3d-point p) n x y z r))
- )
- )
- (vlax-put b 'layer l)
- (command "_.attsync" "_Name" n)
- (vla-delete o)
- )
- )
- (princ)
- )
|