这对我来说很有用:
- (defun c:test ( / acdoc acsel acutl obj )
- (setq acdoc (vla-get-activedocument (vlax-get-acad-object))
- acutl (vla-get-utility acdoc)
- )
- (if (ssget)
- (progn
- (setq acsel (vla-get-activeselectionset acdoc))
- (princ (strcat "\nSelSet Count: " (itoa (vla-get-count acsel))))
- (while
- (not
- (vl-catch-all-error-p
- (vl-catch-all-apply 'vla-getentity
- (list acutl 'obj 'pnt "\nSelect Object to Add: ")
- )
- )
- )
- (vla-additems acsel
- (vlax-make-variant
- (vlax-safearray-fill
- (vlax-make-safearray vlax-vbobject '(0 . 0)) (list obj)
- )
- )
- )
- (princ (strcat "\nSelSet Count: " (itoa (vla-get-count acsel))))
- )
- )
- )
- (princ)
- )
注意,可以使用entsel/vlax-ename->vla-object,但我想把事情搞混 |