本帖最后由 作者 于 2008-12-18 14:19:59 编辑
- ;;;修改任意对象的颜色(MLINE除外)---caoyin
- ;;;龙龙仔版主有这样一个程序,我学着写了一个
- ;;;--------------------------------------------------------------
- (defun c:ChColor (/ SS BLKS I BNLst)
- (if (and (setq SS (lt:ssget '("\n选择要修改颜色的对象: ")))
- (or $ChColor$ (setq $ChColor$ 7))
- (setq $ChColor$ (acad_colordlg $ChColor$))
- )
- (progn
- (setq BLKS (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))))
- (defun ChColor (OBJ / oName BlkName)
- (setq oName (vla-get-ObjectName OBJ))
- (cond
- ((wcmatch oName "*Dimension,AcDbLeader,AcDbFcf")
- (vla-put-DimensionLineColor OBJ $ChColor$)
- (if (wcmatch oName "*Dimension")
- (progn
- (vla-put-ExtensionLineColor OBJ $ChColor$)
- (if (setq BlkName (assoc 2 (entget (vlax-vla-object->ename OBJ))))
- (vlax-for OBJ (vla-item Blks (cdr BlkName))
- (vla-put-color OBJ $ChColor$)
- )
- )
- )
- )
- (if (wcmatch oName "*Dimension,AcDbFcf")
- (vla-put-TextColor OBJ $ChColor$)
- )
- )
- ((= oName "AcDbBlockReference")
- (setq BlkName (vla-get-name OBJ))
- (if (not (member BlkName BNLst))
- (progn
- (setq BNLst (cons BlkName BNLst))
- (vlax-for X (vla-item Blks BlkName)
- (ChColor X)
- )
- )
- )
- (if (= (vla-get-HasAttributes OBJ) :vlax-true)
- (foreach X (vlax-invoke OBJ 'getattributes)
- (vla-put-color X $ChColor$)
- )
- )
- )
- )
- (vla-put-color obj $ChColor$)
- )
- (repeat (setq I (sslength SS))
- (setq OBJ (vlax-ename->vla-object (ssname SS (setq I (1- I)))))
- (ChColor OBJ)
- )
- )
- )
- (princ)
- )
- ;;;-----------------支持函数
- ;; lt:ssget --> 见本帖3楼
|