重写经典---麦版面板dcl 短小精干(20241016传可伸缩版))
本帖最后由 wzg356 于 2024-10-18 20:23 编辑炒冷饭了,顶顶人气,互相经验交流
节前看有关DCL帖子有些多,新年了,也来一波
20241016上传一个可伸缩的版本-底部下载
以下是最初版本
;一直这样使用
;去年疫情影响,空闲多,无聊对主程序(最下面)做了改写,略微精简
;面板函数mainpaneldcl发动程序
(defun c:xx ()(mainpaneldcl(list
(list "常用1"
(list "快速选择" "ss")
;功能名称/命令,这种命令方式可空格/回车重复执行上次
;命令也可以是(*)方式
(list "快速建块" "qblk")
(list "选特定字" "sstxt")
(list "对象替换" "rss")
(list "原位缩放" "scs")
(list "递增复制" "caf")
)
(list "制图环境"
(list "标准外框" "wtk")
(list "建标注样" "dimset")
(list "Dim刷字h" "dimSETtxtsize")
(list "字h刷Dim" "txtSETdimScale")
(list "MY 宋 体" "mysimsunb")
(list "等线仿宋" "myHztxt")
(list "换背景色" "bjs")
(list "MY打印机" "setp")
(list "》a" "laytool");进入子板a
)
))(princ))
(defun c:laytool ()(mainpaneldcl(list
(list "层操作"
(list "层 关 闭" "lcs")
(list "层反关闭" "lcsa")
(list "层 冻 结" "lfs")
(list "层反冻结" "lfsa")
(list "层 锁 定" "lks")
(list "层反锁定" "lksa")
(list "层全打开" "w1")
(list "层全解冻" "w2")
(list "层全解锁" "w3")
(list "三个全部" "w123")
(list "《" "XX");返回主板
)
))(princ))
;面板主程序
(vl-load-com)
(defun mainpaneldcl (strklst / maxl keylst n nn lcmd ff f id cmd)
(setq ff(vl-filename-mktemp "temp_pannel.dcl") f(open ff "w"))
(write-line "MYbutton:button{width =10;vertical_margin=none;horizontal_margin=none;}" f)
(write-line "MYpanel:dialog{label=\"xx工具\";:row{" f)
(setq n 0 nn(mapcar 'length (mapcar 'cdr strklst)) maxl(apply 'max nn));表长
(mapcar (function(lambda(x / l1)
(write-line(strcat ":column{label=" (vl-prin1-to-string(car x))";")f)
(setq x(cdr x) x(append x(repeat(- maxl(length x))(setq l1(cons '("" "")l1)))));表补长
(mapcar (function(lambda(y / k)
(setq k(strcat "key" (itoa(setq n(1+ n)))))
(write-line(strcat
":MYbutton{label="(vl-prin1-to-string(car y))";key= "(vl-prin1-to-string k)
(if(= (setq y(cadr y)) "")";is_enabled = false;}" ";}");填充的空白键
)f)
(setq keylst(cons k keylst) lcmd(cons y lcmd));键表key1开始/命令表
))x)
(write-line "}" f)
))strklst)
(write-line "}:row{" f)
(write-line(if(> (length nn)2)":text{label=\"盛年不再来!岁月不待人!\";is_enabled = false;}" "spacer_0;")f)
(write-line":button{label=\"关闭\"; key=\"cancel\";is_cancel=true;width=6;fixed_width=true;}" f)
(write-line "spacer_0;}}" f)
(close f)
(setq id(load_dialog ff))(vl-file-delete ff)
(new_dialog "MYpanel" id "3" P_MYpaneldcl)
(mapcar (function(lambda(x)(action_tile x(strcat "(setq P_MYpaneldcl(done_dialog "(substr x 4)"))"))))keylst)
(setq n (start_dialog))(unload_dialog id)
(if(> n 0)(if(wcmatch(setq cmd(nth(1- n)(reverse lcmd))) "(*)")(eval(read cmd));(函数)方式
(vla-SendCommand(vla-get-ActiveDocument(vlax-get-acad-object))(strcat cmd "\n"));c:命令方式,方便重复执行
));点击按钮的值
)
;快捷键---图层控制
(defun c:ww ()
(mainpaneldcl
(list
(list "图层控制tcg"
(list "图层关闭/l-" "layoff")
(list "图层关闭(反)/tcgbf" "tcgbf")
(list "全部显示/`" "layon")
(list "孤立图层/q" "layiso")
(list "退出孤立/qq" "layuniso")
)
))
(princ))
;面板主程序
(vl-load-com)
(defun mainpaneldcl (strklst / maxl keylst n nn lcmd ff f id cmd)
(setq ff(vl-filename-mktemp "temp_pannel.dcl") f(open ff "w"))
(write-line "MYbutton:button{width =10;vertical_margin=none;horizontal_margin=none;}" f)
(write-line "MYpanel:dialog{label=\"xx工具\";:row{" f)
(setq n 0 nn(mapcar 'length (mapcar 'cdr strklst)) maxl(apply 'max nn));表长
(mapcar (function(lambda(x / l1)
(write-line(strcat ":column{label=" (vl-prin1-to-string(car x))";")f)
(setq x(cdr x) x(append x(repeat(- maxl(length x))(setq l1(cons '("" "")l1)))));表补长
(mapcar (function(lambda(y / k)
(setq k(strcat "key" (itoa(setq n(1+ n)))))
(write-line(strcat
":MYbutton{label="(vl-prin1-to-string(car y))";key= "(vl-prin1-to-string k)
(if(= (setq y(cadr y)) "")";is_enabled = false;}" ";}");填充的空白键
)f)
(setq keylst(cons k keylst) lcmd(cons y lcmd));键表key1开始/命令表
))x)
(write-line "}" f)
))strklst)
(write-line "}:row{" f)
(write-line(if(> (length nn)2)":text{label=\"盛年不再来!岁月不待人!\";is_enabled = false;}" "spacer_0;")f)
(write-line":button{label=\"关闭\"; key=\"cancel\";is_cancel=true;width=6;fixed_width=true;}" f)
(write-line "spacer_0;}}" f)
(close f)
(setq id(load_dialog ff))(vl-file-delete ff)
(new_dialog "MYpanel" id "3" P_MYpaneldcl)
(mapcar (function(lambda(x)(action_tile x(strcat "(setq P_MYpaneldcl(done_dialog "(substr x 4)"))"))))keylst)
(setq n (start_dialog))(unload_dialog id)
(if(> n 0)(if(wcmatch(setq cmd(nth(1- n)(reverse lcmd))) "(*)")(eval(read cmd));(函数)方式
(vla-SendCommand(vla-get-ActiveDocument(vlax-get-acad-object))(strcat cmd "\n"));c:命令方式,方便重复执行
));点击按钮的值
)我的程序汉字面板为什么是乱码的啊? decemc 发表于 2024-10-17 13:06
大佬,我一直用你之前的面板,刚试过了最新的版本,默认是收缩的,个人觉得不太方便,还有就是每列的对齐, ...
第一个问题,稍有接触lsp就可以改啊
(if mytoolgnall strklst0(list(car strklst0)(cadr strklst0)))
改为
(if mytoolgnall (list(car strklst0)(cadr strklst0))strklst0)
":button{label=\""(if mytoolgnall "《" "》")"\"; key=\"key1\";width=4;}"
改为
":button{label=\""(if mytoolgnall "》" "《")"\"; key=\"key1\";width=4;}"
第二个问题,这种改法不通用,也失去简洁的意义了,自己继续学习试做修改吧
Qwer1243 发表于 2024-10-14 16:24
我也想问这个,感觉太挤了,看着有点眼花
(write-line "MYbutton:button{width =10;vertical_margin=none;horizontal_margin=none;}" f)
改为
(write-line "MYbutton:button{width =10;horizontal_margin=none;}" f)
或
(write-line "MYbutton:button{width =10;}" f) 谢谢楼主分享 谢谢分享! 老大,复制试了一下,太牛了。。。。 謝謝樓主分享 🐮感谢分享源码! 手机上看,有运行时截图吗
老迈的好像还带自定义命令的,你精简掉了吗
老迈的好像还带自定义命令的,你精简掉了吗謝謝樓主分享!!!! 很好,谢谢分享。