- ;; 用LISP遍歷修改物件属性;;(chh (ssget '((0 . "insert"))))
- ;;这是一个简单例子--只修改图块(COLOR=BYBLOCK)
- ;;(因它不支持---嵌套块 & 标註 & 公差 & 引线)
- ;;希望对你有帮助
- ;;BY LUCAS
- (defun CHH (SS / ENTT ENT COL ATT CATT ENT1 EN N COL LST)
- (if (and SS
- (setq COL (acad_colordlg 7))
- )
- (progn
- (setq N 0)
- (repeat (sslength SS)
- (setq ENT (vlax-ename->vla-object (ssname SS N)))
- (vla-put-color ENT COL)
- (if (= (vl-catch-all-apply 'vla-get-hasattributes (list ENT))
- :vlax-true
- )
- (progn
- (setq ATT (vlax-variant-value (vla-getattributes ENT))
- CATT (vlax-variant-value
- (vla-getconstantattributes ENT)
- )
- )
- (if (safearray-value ATT)
- (foreach ENT1 (vlax-safearray->list ATT)
- (vla-put-color ENT1 COL)
- )
- )
- (if (safearray-value CATT)
- (foreach ENT1 (vlax-safearray->list CATT)
- (vla-put-color ENT1 COL)
- )
- )
- )
- )
- (if (not (member (vla-get-name ENT) LST))
- (progn
- (setq LST (cons (vla-get-name ENT) LST))
- (vlax-for EN
- (vla-item (vla-get-blocks
- (vla-get-activedocument
- (vlax-get-acad-object)
- )
- )
- (vla-get-name ENT)
- )
- (vla-put-color EN 0)
- )
- )
- )
- (setq N (1+ N))
- )
- )
- )
- (princ)
- )
|