xiaocainiao 发表于 2024-5-6 15:35:05

求教!如何利用现有表数据批量设置快捷键

本帖最后由 xiaocainiao 于 2024-5-8 19:03 编辑

;图层切换
(defun lay_qh (lay lay_col lay_lt / lay_s)
(setq lay_s (tblsearch "layer" lay))
(if (= lay_s nil)
    (command "-layer" "n" lay "c" lay_col lay "lay_lt" lay_lt lay "")
)
(setvar "clayer" lay)
)

(defun c:DEF()(lay_qh "Defpoints" 7 "Continuous"))
(defun c:00()(lay_qh "Defpoints" 7 "Continuous"))
(defun c:QT()(lay_qh "墙体" 5 "Continuous"))
上面是我目前使用的图层切换代码、
有多少个图层就要复制多少行代码、然后再修改快捷键和对应图层线性、感觉有点麻烦


现在我把快捷键和图层信息都放在表里面、代码如下:
(setq lay_lst (("DEF" "Defpoints" "7" "Continuous") ("00" "0" "7" "Continuous") ("QT" "墙体" "5" "Continuous")))然后想着根据表信息来批量创建图层切换快捷键、
不知道用Lisp能否实现、特来请教一下各位大神!


xtjd 发表于 2024-5-6 15:35:06

(foreach l lay_lst(eval (read (strcat "(defun c:"(car l)"()(lay_qh \""(cadr l)"\" "(caddr l)" \""(last l)"\"))"))))

xiaocainiao 发表于 2024-5-6 16:39:21

http://bbs.mjtd.com/forum.php?mod=viewthread&tid=188146&highlight=%BF%EC%BD%DD%BC%FC

论坛上找到了一个类似的帖子、不过没太看懂代码

xiaocainiao 发表于 2024-5-6 17:57:11

xtjd 发表于 2024-5-6 15:35
(foreach l lay_lst(eval (read (strcat "(defun c:"(car l)"()(lay_qh \""(cadr l)"\" "(caddr l)" \""(la ...

谢谢、这个可以
页: [1]
查看完整版本: 求教!如何利用现有表数据批量设置快捷键