- UID
- 185525
- 积分
- 0
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2004-10-21
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
各位大哥,小弟求一个多义线宽度刷的lisp程序
功能如下:能想格式刷一样,把多义线的宽度刷成参考对象的宽度,包括能将line线刷成多义线且带有参考对象的宽度。
谢谢。
已经解决,谢谢南京市市政设计研究院 嵇龙
(princ "\n**宽度格式刷,自由软件,版本号 1.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:sz(/ 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)
) |
|