明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1183|回复: 6

图层切换功能优化

[复制链接]
发表于 2020-11-3 12:33 | 显示全部楼层 |阅读模式
2明经币
已有两种图层切换程序:
(Defun C:aq ()
        (prompt "***切换到【001-建筑-墙体】")
                (if (= (TBLOBJNAME "LAYER" "001-建筑-墙体") nil)
                (command "layer" "m" "001-建筑-墙体" "c" "7" "" "")
                (setvar "clayer" "001-建筑-墙体")
                )
        (setq SS (ssget))
        (if (/= ss nil)
        (Command "CHANGE" SS "" "P" "la" "001-建筑-墙体" "")
        )
        (princ)
)


(Defun C:JD (/ key lay ss)
        (initget "1 2 3 4 5 6")
        (setq key (getkword "\n选择图层[墙体粗线(1)/完成面中粗(2)/基层中细(3)/细线(4)/填充淡显(5)/尺寸细线(6)]:<基层中细>"))
        (cond
        ((= key "1")(setq lay "008-节点-墙体粗线"))
        ((= key "2")(setq lay "008-节点-完成面中粗"))
        ((= key "3")(setq lay "008-节点-基层中细"))
        ((= key "4")(setq lay "008-节点-细线"))
        ((= key "5")(setq lay "008-节点-填充淡显"))
        ((= key "6")(setq lay "008-节点-尺寸细线"))
        ((= key nil)(setq lay "008-节点-基层中细"))
        )
        (prompt (strcat "***切换到【" lay "】"))
                (if (= (TBLOBJNAME "LAYER" lay) nil)
                (command "layer" "m" lay "c" "7" "" ""))
        (setvar "clayer" lay)
                       (setq SS (ssget))
        (if (/= ss nil)
                (Command "CHANGE" SS "" "P" "la" lay "")
        )
        (princ)
)


想要优化成:
1.按AQ命令后如没有选择物体,那么点两下右键(回车或者空格),将建筑墙体层切换为当前层。
2.按AQ命令后选择物体,那么只有选择的物体图层改变,但是当前层不变。

最佳答案

查看完整内容

(Defun C:aq () (prompt "***切换到【001-建筑-墙体】") (if (= (TBLOBJNAME "LAYER" "001-建筑-墙体") nil) (entmake (list '(0 . "LAYER") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbLayerTableRecord") '(70 . 0) '(62 . 7)(cons 2 "001-建筑-墙体"))) ) (setq SS (ssget)) (if (/= ss nil) (Command "CHANGE ...
发表于 2020-11-3 12:33 | 显示全部楼层
(Defun C:aq ()
        (prompt "***切换到【001-建筑-墙体】")
                (if (= (TBLOBJNAME "LAYER" "001-建筑-墙体") nil)
                (entmake (list '(0 . "LAYER") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbLayerTableRecord") '(70 . 0) '(62 . 7)(cons 2 "001-建筑-墙体")))
               
                )
        (setq SS (ssget))
        (if (/= ss nil)
        (Command "CHANGE" SS "" "P" "la" "001-建筑-墙体" "")
        (setvar "clayer" "001-建筑-墙体"))
        (princ)
)
回复

使用道具 举报

 楼主| 发表于 2020-11-3 17:12 | 显示全部楼层
start4444 发表于 2020-11-3 12:33
(Defun C:aq ()
        (prompt "***切换到【001-建筑-墙体】")
                (if (= (TBLOBJNAME "L ...

谢谢,就是这样的效果。另外问下entmake与command是一样的效果吧

点评

功能一样,command 会转为当前层  发表于 2020-11-3 17:37
回复

使用道具 举报

 楼主| 发表于 2020-11-3 17:49 | 显示全部楼层
谢谢!
回复

使用道具 举报

发表于 2024-2-12 14:36 | 显示全部楼层
http://bbs.mjtd.com/thread-70009-1-1.html,图层工具还是这个厉害
回复

使用道具 举报

发表于 2024-2-17 13:29 | 显示全部楼层
atone 发表于 2024-2-12 14:36
http://bbs.mjtd.com/thread-70009-1-1.html,图层工具还是这个厉害

分享的切换图层工具真的很厉害!!路过也能捡到宝。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-2 00:23 , Processed in 1.798501 second(s), 22 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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