怎么做快速切换线型的控制面板?
本帖最后由 zilong136 于 2024-1-14 22:06 编辑类似这种图层切换面板,既可以在命令行选择,又可以在面板选择,可同时选多个对象,即选即改。
如何修改下面这些代码?要求默认保留上一次选择图层?
;;重画选择集中的对象-----(一级)-----
;;Sel为选择集或图元名; mode为方式码
;;mode 1 在屏幕重画该选择集对象
;;mode 2 隐藏该选择集对象
;;mode 3 <醒目显示> 该选择集对象
;;mode 4 取消<醒目显示>该选择集对象
(defun sl-sel-redrawsel (sel mode / n)
(if sel
(cond
((= 'PICKSET (type sel))
(repeat (setq n (sslength sel))
(redraw (ssname sel (setq n (1- n))) mode)
)
)
((= 'ENAME (type sel))
(redraw sel mode)
)
)
)
t
)
(defun C:W4 (/ key nm-gg ss)
(defun nm-gg (ss tc co lt)
(if (not (tblsearch "layer" tc))
(command "-layer" "m" tc "c" "3" "" "")
)
(command "CHPROP" ss "" "la" tc "c" co "LT" lt "")
)
(while (setq ss (ssget ":S"))
(sl-sel-redrawsel ss 3) ;亮显
(initget 1 "0 1 2 3 4 5")
(setq key (getkword "\n 选择图层"))
(cond ;;;(nm-gg ss "图层0" "COL" "LT")
((= key "0")
(nm-gg ss "图层0" "bylayer" "bylayer")
)
((= key "1")
(nm-gg ss "图层1" "1" "bylayer")
)
((= key "2")
(nm-gg ss "图层2" "2" "bylayer")
)
((= key "3")
(nm-gg ss "图层3" "3" "bylayer")
)
((= key "4")
(nm-gg ss "图层4" "4" "bylayer")
)
((= key "5")
(nm-gg ss "图层5" "5" "bylayer")
)
)
(sssetfirst nil nil) ;取消亮显
)
(princ)
)
(princ "\n****W4图层切换****") (princ)
本帖最后由 xj6019 于 2024-1-14 18:54 编辑
(defun C:NM (/ key nm-gg ss)
(defun NM-GG (ss tc CO LT)
(if (not (tblsearch "layer" tc))
(command "-layer" "m" tc "c" "3" "" "")
)
(command "CHPROP" ss "" "la"tc "c" CO "LT" LT"")
)
(setq ss(ssget))
(initget 1 "0 1 2 3 4 5")
(setq key
(getkword
"\n 选择图层")
)
(cond ;;;(NM-GG SS "图层0" "COL" "LT")
((= key "0")
(NM-GG SS "图层0" "bylayer" "bylayer")
)
((= key "1")
(NM-GG SS "图层1" "1" "bylayer")
)
((= key "2")
(NM-GG SS "图层2" "2" "bylayer")
)
((= key "3")
(NM-GG SS "图层3" "3" "bylayer")
)
((= key "4")
(NM-GG SS "图层4" "4" "bylayer")
)
((= key "5")
(NM-GG SS "图层5" "5" "bylayer")
)
)
(princ)
)
(defun C:NM (/ key ss)
(setq ss(ssget))
(initget 1 "0 1 2 3 4 5")
(setq key
(getkword
"\n 选择图层")
)
(cond
((= key "0")
(command"CHPROP" ss "" "la" "图层0""")
)
((= key "1")
(command"CHPROP" ss "" "la" "图层1""")
)
((= key "2")
(command"CHPROP" ss "" "la" "图层2""")
)
((= key "3")
(command"CHPROP" ss "" "la" "图层3""")
)
((= key "4")
(command"CHPROP" ss "" "la" "图层4""")
)
((= key "5")
(command"CHPROP" ss "" "la" "图层5""")
)
)
(princ)
) 本帖最后由 zilong136 于 2024-1-14 13:51 编辑
xj6019 发表于 2024-1-14 09:37
(defun C:NM (/ key ss)
(setq ss(ssget))
(initget 1 "0 1 2 3 4 5")
这个只切换图中已存在的图层,能不能优化一下,原图中没的该图层的话就直接新建,有的话就直接切换?
还有颜色、线型也可以加上。
xj6019 发表于 2024-1-14 14:12
(defun C:NM (/ key nm-gg ss)
(defun NM-GG (ss tc CO LT)
(if (not (tblsearch "layer" tc))
你这个还是不能新建图层,只能改为原图纸中已存在的图层。 xj6019 发表于 2024-1-14 14:12
(defun C:NM (/ key nm-gg ss)
(defun NM-GG (ss tc CO LT)
(if (not (tblsearc ...
恩,这个可以,能不能再加一个功能,默认保留上一次选择的图层? 大神牛B,学习了
页:
[1]