普通块批量修改直线与文字颜色-源码
本帖最后由 zhangcan0515 于 2020-10-7 22:40 编辑使用方法
1操作是在位编辑块然后框选图块运行下列代码
(defun c:tt( / ssg ssg1 ssg2)
(setq ssg (ssget ":s" '((0 . "TEXT,mtext,line"))))
(setq ssg1 (ssget "p" '((0 . "TEXT,mtext"))))
(command "._Select" ssg "_Remove" ssg1 "")
(setq ssg2 (ssget "p"))
(command "change" ssg1 "" "p" "La" "8文字层" "" );文字放在文字层
(command "change" ssg2 "" "p" "La" "2细实线" "" );直线放在细实线层
(command "change" "all" "" "P" "C" "ByLayer" "LT" "ByLayer" "")
(command "EXPLODE" ssg "" "p" "" )
(princ)
)
以下是明经大佬:wzg356写的也分享给大家共大家学习
(defun c:tt8 ( / ss en x)
(setq ss (ssget '((0 . "insert"))))
(foreach en
(vl-remove-if
'(lambda(x)(/= (type x) 'ENAME))
(mapcar 'cadr (ssnamex ss));栏选只要这句即可
);图元名列表
(setblk en)
)
)
;修改块内文字、直线颜色(setblk)
(defun setblk (en / e)
(setq e (TBLOBJNAME "block" (cdr(assoc 2(entget en)))))
(while(setq e (entnext e))
(cond
((= (cdr(assoc 0(entget e))) "TEXT")
(setdxf e (cons 62 3));修改颜色为绿色
)
((= (cdr(assoc 0(entget e))) "LINE")
(setdxf e (cons 62 1));修改颜色为红色
)
(t nil)
)
)
(entupd en);更新显示
)
;按新的点对表修改组码表更新图元
;(setdxf (car(entsel)) (cons 62 1))
(defun setdxf(en xin / enb)
(if(assoc (car xin) (setq enb (entget en)))
(entmod(subst xin (assoc (car xin) enb)enb))
(entmod (cons xin enb))
)
)
最近在研究块留个脚印
页:
[1]