试试这个未经测试的快速示例。
- (defun c:test (/ _getattvalue en in ss val)
- ;; RJP - Simple get attribute value sub .. no error checking
- (defun _getattvalue (block tag)
- (vl-some
- '(lambda (att) (cond ((= (strcase tag) (vla-get-tagstring att)) (vla-get-textstring att))))
- (vlax-invoke block 'getattributes)
- )
- )
- ;; RJP - added (66 . 1) to filter ( attributed blocks )
- (if (setq
- ss (ssget "_C" '(7.244 2.071) '(16.665 10.003) '((0 . "INSERT") (8 . "FTG-Iso") (66 . 1)))
- )
- (foreach en (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
- (if (and ;; If we have a value, and it does not match the filter then remove item from selection
- (setq val (_getattvalue (vlax-ename->vla-object en) "Description"))
- (wcmatch val "AAA,BBB,CCC")
- )
- (ssdel en ss)
- )
- )
- )
- ;; Highlight selection
- (sssetfirst nil ss)
- (princ)
- )
|