明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1744|回复: 0

帮忙简化程序 《宽度格式刷》

[复制链接]
发表于 2005-5-4 13:27:00 | 显示全部楼层 |阅读模式
把这个刷子的功能简化为:只刷宽度,其他的层、颜色等都不刷 (defun sz_s()
(setq wd1 "\n当前匹配属性:" wd0 "不匹配属性:")
(if (= sz_color 1) (setq wd1 (strcat wd1 " 颜色")) (setq wd0 (strcat wd0 " 颜色")))
(if (= sz_layer 1) (setq wd1 (strcat wd1 " 图层")) (setq wd0 (strcat wd0 " 图层")))
(if (= sz_ltype 1) (setq wd1 (strcat wd1 " 线形")) (setq wd0 (strcat wd0 " 线形")))
(if (= sz_ltsca 1) (setq wd1 (strcat wd1 " 线形比例")) (setq wd0 (strcat wd0 " 线形比例")))
(if (= sz_asywh 1) (setq wd1 (strcat wd1 " 变宽线形")) (setq wd0 (strcat wd0 " 变宽线形")))
(if (= wd1 "\n当前匹配属性:") (setq wd1 "\n当前匹配属性:宽度")(setq wd1 (strcat wd1 "。")))
(if (= wd0 "不匹配属性:") (setq wd0 "") (setq wd0 (strcat wd0 "。")))
(princ (strcat "\n***" wd1 wd0))
(initget "1 2 3 4 5")
(setq setk(getkword "\n改变:颜色1/图层2/线形3/线形比例4/变宽线形5/<确认>:"))
(cond
((= setk "1") (if (= sz_color 1) (setq sz_color 0) (setq sz_color 1)) (sz_s))
((= setk "2") (if (= sz_layer 1) (setq sz_layer 0) (setq sz_layer 1)) (sz_s))
((= setk "3") (if (= sz_ltype 1) (setq sz_ltype 0) (setq sz_ltype 1)) (sz_s))
((= setk "4") (if (= sz_ltsca 1) (setq sz_ltsca 0) (setq sz_ltsca 1)) (sz_s))
((= setk "5") (if (= sz_asywh 1) (setq sz_asywh 0) (setq sz_asywh 1)) (sz_s))
(t nil)
)
) (defun sz_b(num enum um / j b0 bj)
(if (and (assoc num ei) enum)
(setq ei (subst enum (assoc num ei) ei))
(if enum
(setq ei (reverse (cons enum (reverse ei))))
(if (assoc num ei)
(progn
(setq j -1
b0 nil
)
(repeat (length ei)
(setq j (1+ j)
bj(nth j ei)
)
(if (/= bj (assoc num ei))
(setq b0 (cons bj b0))
(if um (setq b0 (cons (cons num um) b0)))
)
)
(setq ei (reverse b0))
)
)
)
)
) (defun sz_main()
(setq len (sslength ss1)
i -1
ent0(entget (car ent1))
e62 (assoc 62 ent0)
e8 (assoc 8 ent0)
e6 (assoc 6 ent0)
e48 (assoc 48 ent0)
e43 (assoc 43 ent0)
e90 (cdr (assoc 90 ent0))
)
(if (>= e90 3)
(progn
(repeat 3 (setq ent0 (subst (cons 11 (cdr (assoc 10 ent0))) (assoc 10 ent0) ent0)))
(setq ent0 (reverse ent0)
ent0 (reverse (cons (car ent0) (cdr (member (assoc 11 ent0) ent0))))
ent0 (subst '(90 . 2) (assoc 90 ent0) ent0)
)
(repeat 2 (setq ent0 (subst (cons 10 (cdr (assoc 11 ent0))) (assoc 11 ent0) ent0)))
)
)
(repeat len
(setq i (1+ i)
eni (ssname ss1 i)
ei (entget eni)
)
(cond
((= (cdr (assoc 0 ei)) "LWPOLYLINE")
(sz_lwp)
)
((= (cdr (assoc 0 ei)) "LINE")
(sz_line)
)
((= (cdr (assoc 0 ei)) "ARC")
(sz_arc)
)
((= (cdr (assoc 0 ei)) "CIRCLE")
(sz_circle)
)
(t nil)
)
)
) (defun sz_lwp()
(if (= sz_color 1) (sz_b 62 e62 256))
(if (= sz_layer 1) (setq ei (subst e8 (assoc 8 ei) ei)))
(if (= sz_ltype 1) (sz_b 6 e6 "BYLAYER"))
(if (= sz_ltsca 1) (sz_b 48 e48 1.0))
(if (assoc 43 ei)
(setq ei (subst e43 (assoc 43 ei) ei))
(if (= sz_asywh 1)
(setq ei (reverse (cons e43 (reverse ei))))
)
)
(entmod ei)
(entupd eni)
) (defun sz_line(/ ei62 ei8 ei6 ei48 ei10 ei11)
(setq ei62 (assoc 62 ei)
ei8 (assoc 8 ei)
ei6 (assoc 6 ei)
ei48 (assoc 48 ei)
ei10 (assoc 10 ei)
ei11 (assoc 11 ei)
)
(setq ei (subst (assoc 5 ei) (assoc 5 ent0) ent0)
ei (subst (cons 70 0) (assoc 70 ei) ei)
)
(if (= sz_color 0) (sz_b 62 ei62 256))
(if (= sz_layer 0) (setq ei (subst ei8 (assoc 8 ei) ei)))
(if (= sz_ltype 0) (sz_b 6 ei6 "BYLAYER"))
(if (= sz_ltsca 0) (sz_b 48 ei48 1.0))
(setq ei (subst (cons 12 (cdr ei10)) (assoc 10 ei) ei)
ei (subst (cons 10 (cdr ei11)) (assoc 10 ei) ei)
ei (subst ei10 (assoc 12 ei) ei)
)
(repeat 2 (setq ei (subst (cons 42 0.0) (assoc 42 ei) ei)))
(entdel eni)
(entmake ei)
) (defun sz_circle(/ ei62 ei8 ei6 ei48 ei10 ei40 pt1 pt2)
(setq ei62 (assoc 62 ei)
ei8 (assoc 8 ei)
ei6 (assoc 6 ei)
ei48 (assoc 48 ei)
ei10 (cdr (assoc 10 ei))
ei40 (cdr (assoc 40 ei))
pt1 (cons (- (car ei10) ei40) (cdr ei10))
pt2 (cons (+ (car ei10) ei40) (cdr ei10))
)
(setq ei (subst (assoc 5 ei) (assoc 5 ent0) ent0)
ei (subst (cons 70 1) (assoc 70 ei) ei)
)
(if (= sz_color 0) (sz_b 62 ei62 256))
(if (= sz_layer 0) (setq ei (subst ei8 (assoc 8 ei) ei)))
(if (= sz_ltype 0) (sz_b 6 ei6 "BYLAYER"))
(if (= sz_ltsca 0) (sz_b 48 ei48 1.0))
(setq ei (subst (cons 12 pt1) (assoc 10 ei) ei)
ei (subst (cons 10 pt2) (assoc 10 ei) ei)
ei (subst (cons 10 pt1) (assoc 12 ei) ei)
)
(repeat 2 (setq ei (subst (cons 42 1.0) (assoc 42 ei) ei)))
(entdel eni)
(entmake ei)
) (defun sz_arc(/ ei62 ei8 ei6 ei10 ei48 ei40 ei50 ei51 pt1 pt2 lpt alf e42)
(setq ei62 (assoc 62 ei)
ei8 (assoc 8 ei)
ei6 (assoc 6 ei)
ei48 (assoc 48 ei)
ei10 (cdr (assoc 10 ei))
ei40 (cdr (assoc 40 ei))
ei50 (cdr (assoc 50 ei))
ei51 (cdr (assoc 51 ei))
pt1 (list (+ (car ei10) (* ei40 (cos ei50)))
(+ (cadr ei10) (* ei40 (sin ei50))) (caddr ei10))
pt2 (list (+ (car ei10) (* ei40 (cos ei51)))
(+ (cadr ei10) (* ei40 (sin ei51))) (caddr ei10))
lpt (/ (distance pt1 pt2) 2.0)
alf (- ei51 ei50)
)
(setq ei (subst (assoc 5 ei) (assoc 5 ent0) ent0)
ei (subst (cons 70 0) (assoc 70 ei) ei)
)
(if (= sz_color 0) (sz_b 62 ei62 256))
(if (= sz_layer 0) (setq ei (subst ei8 (assoc 8 ei) ei)))
(if (= sz_ltype 0) (sz_b 6 ei6 "BYLAYER"))
(if (= sz_ltsca 0) (sz_b 48 ei48 1.0))
(setq ei (subst (cons 12 pt1) (assoc 10 ei) ei)
ei (subst (cons 10 pt2) (assoc 10 ei) ei)
ei (subst (cons 10 pt1) (assoc 12 ei) ei)
)
(if (or (> alf pi) (and (< alf 0) (> alf (- pi))))
(setq e42 (/ (+ ei40 (sqrt (- (* ei40 ei40) (* lpt lpt)))) lpt)
ei (subst (cons 42 e42) (assoc 42 ei) ei)
)
(setq e42 (/ (- ei40 (sqrt (- (* ei40 ei40) (* lpt lpt)))) lpt)
ei (subst (cons 42 e42) (assoc 42 ei) ei)
)
)
(entdel eni)
(entmake ei)
) (defun sz_ss()
(setq wd1 "\n当前匹配属性:" wd0 "不匹配属性:")
(if (= sz_color 1) (setq wd1 (strcat wd1 " 颜色")) (setq wd0 (strcat wd0 " 颜色")))
(if (= sz_layer 1) (setq wd1 (strcat wd1 " 图层")) (setq wd0 (strcat wd0 " 图层")))
(if (= sz_ltype 1) (setq wd1 (strcat wd1 " 线形")) (setq wd0 (strcat wd0 " 线形")))
(if (= sz_ltsca 1) (setq wd1 (strcat wd1 " 线形比例")) (setq wd0 (strcat wd0 " 线形比例")))
(if (= sz_asywh 1) (setq wd1 (strcat wd1 " 变宽线形")) (setq wd0 (strcat wd0 " 变宽线形")))
(if (= wd1 "\n当前匹配属性:") (setq wd1 "\n当前匹配属性:宽度")(setq wd1 (strcat wd1 "。")))
(if (= wd0 "不匹配属性:") (setq wd0 "") (setq wd0 (strcat wd0 "。")))
(princ (strcat "\n***" wd1 wd0))
(initget "Setting ")
(setq ent1(entsel "\n设置匹配属性S/<拾取参考宽度多义线:>"))
(if (= ent1 "Setting")
(progn
(sz_s)
(sz_ss)
)
(progn
(if ent1
(if (/= (type ent1) 'STR)
(progn
(if (/= (cdr (assoc 0 (entget (car ent1)))) "LWPOLYLINE") (sz_ss))
(if (not (assoc 43 (entget (car ent1)))) (sz_ss))
)
)
(sz_ss)
)
)
)
) (defun c:QQ(/ ent1 ent0 wd0 wd1 setk ss1 len i e62 e8 e6 e48 e90 e43 ei eni)
(command "color" (getvar "cecolor"))
(if (not sz_color) (setq sz_color 1))
(if (not sz_layer) (setq sz_layer 1))
(if (not sz_ltype) (setq sz_ltype 1))
(if (not sz_ltsca) (setq sz_ltsca 1))
(if (not sz_asywh) (setq sz_asywh 0))
(sz_ss)
(if (/= (type ent1) 'STR)
(progn
(princ "\n拾取欲变宽度的线实体:")
(setq ss1 (ssget '((-4 . "<OR")(0 . "CIRCLE")(0 . "LINE")(0 . "ARC")(0 . "LWPOLYLINE")(-4 . "OR>"))))
(if ss1
(sz_main)
)
)
)
(princ)
)
"觉得好,就打赏"
还没有人打赏,支持一下
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-17 04:54 , Processed in 0.174534 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表