根据斑主的指示,已将 Attribute 改好,但标注的尺寸是改的不是很好的...
我看了一下,觉得应该要将 dimstyle 中的 textColor ExtensionLineColor DimensionLineColor 设成 0即 ByBlock才行的...
还请版主明示......
(Defun c:tt2 (/ ss color layer i *AcadDocument* blocks vn) ;; 子程序 . (Defun sub_Fun (vn / atts) (vla-put-color vn color) (vla-put-layer vn layer) (cond ((and (= (vla-get-objectname vn) "AcDbBlockReference") (= (vla-get-hasAttributes vn) :vlax-true)) (setq atts (vlax-safeArray->list (vlax-variant-value (vla-getAttributes vn)))) (foreach att atts (vla-put-color att color) (vla-put-layer att layer)) ) ) (vlax-for ent (vla-item blocks (vla-get-name vn)) (vla-put-color ent color) (vla-put-layer ent layer) (cond ((wcmatch (vla-get-objectName ent) "AcDb*Dimension") (vla-put-DimensionLineColor ent color) (vla-put-textColor ent color) (vla-put-ExtensionLineColor ent color) ) ) (if (= (vla-get-objectname ent) "AcDbBlockReference") (sub_Fun ent) ) ) ) ;; 程序开始 . (vl-load-com) (princ "\n选要改颜色的块: ") (setq ss (vl-catch-all-apply 'ssget '(((0 . "INSERT"))))) (cond ((or (vl-catch-all-error-p ss) (null ss)) (vl-exit-with-value 0))) ;; 设定这个要改的 color=8,layer="图块" (假设 "图块"层一定存在) . (setq color 8 layer "图块" ) (setq i 0 *AcadDocument* (vla-get-activeDocument (vlax-get-acad-object)) blocks (vla-get-blocks *AcadDocument*) ) (repeat (sslength ss) (setq vn (vlax-ename->vla-object (ssname ss i)) i (1+ i) ) ;; 防止出错 . (sub_Fun vn) ) (prin1) )
|