CAD层的快速转换-----“change”出的快速世界
来看一些lisp语句,有兴趣的朋友可以将这些语句添加到acad。lsp文件中去。;变换当前层
(DEFUN C: L0 () (COMMAND "LAYER" "M" "0" "c" "7" "" "lw" "0.05" "" ""))
(DEFUN C: L1 () (COMMAND "LAYER" "M" "1" "c" "1" "" "lw" "0.05" "" ""))
(DEFUN C: L2 () (COMMAND "LAYER" "M" "2" "c" "2" "" "lw" "0.25" "" ""))
(DEFUN C: L3 () (COMMAND "LAYER" "M" "3" "c" "3" "" "lw" "0.15" "" ""))
(DEFUN C: L4 () (COMMAND "LAYER" "M" "4" "c" "4" "" "lw" "0.05" "" ""))
(DEFUN C: L5 () (COMMAND "LAYER" "M" "5" "c" "5" "" "lw" "0.15" "" ""))
(DEFUN C: L6 () (COMMAND "LAYER" "M" "6" "c" "6" "" "lw" "0.09" "" ""))
(DEFUN C: L8 () (COMMAND "LAYER" "M" "8" "c" "30" "" "lw" "0.09" "" ""))
(DEFUN C: L- () (COMMAND "LAYER" "M" "-" "c" "7" "" "lw" "0.05" "" ""))
下面是演示动画,注意看层的颜色。
http://au.autodesk.com.cn/bbs/images/default/attachimg.gif http://au.autodesk.com.cn/bbs/attachments/forumid_43/11090515178a4380bf9cdb33a1.gif
下面是快速转换层的lisp程序
;改变元素层或颜色
(defun C:C0 ()
(ssget)
(command "change" "p" "" "P" "l a" "0" ""))
(defun C:C1 ()
(ssget)
(command "change" "p" "" "P" "l a" "1" ""))
(defun C:C2 ()
(ssget)
(command "change" "p" "" "P" "l a" "2" ""))
(defun C:C3 ()
(ssget)
(command "change" "p" "" "P" "l a" "3" ""))
(defun C:C4 ()
(ssget)
(command "change" "p" "" "P" "la" "4" ""))
(defun C:C5 ()
(ssget)
(command "change" "p" "" "P" "l a" "5" ""))
(defun C:C6 ()
(ssget)
(command "change" "p" "" "P" "l a" "6" ""))
(defun C:C8 ()
(ssget)
(command "change" "p" "" "P" "l a" "8" ""))
下面是演示动画
http://au.autodesk.com.cn/bbs/images/default/attachimg.gif http://au.autodesk.com.cn/bbs/attachments/forumid_43/1109051524e59c9fc1fcd152c5.gif 下载 (418.72 KB)
2011-9-5 15:24
通过上述方法可以不用点开layer窗口直接把要改层的图素直接改变层。达到方便快捷的目的,同时上面的命令从C1-C8均适合记忆。实际上是调用Change命令直接修改图素。
同时也解答了以前对层名的约束,最好不要用“粗线层”“中心线”等中文名的原因。
同样,对于上述命令的扩展也可以派生出许多其他命令,可以让程序在若干不同层的图素中自动寻找相应的层,并改变它们。
下面是演示动画。
http://au.autodesk.com.cn/bbs/images/default/attachimg.gif http://au.autodesk.com.cn/bbs/attachments/forumid_43/1109051539eece9f60686f48b2.gif
实际上楼主想的太简单了,现实绘图中,会能很多限制条件的。
①先判断有无该图层,无则新建,有则须进一步判断
②对已有图层,要判断有无冻结、锁定等情况,有则要解冻,解锁
③对选择对象移层,要先判断是否选择了对象,空集会使命令错误。 G〆h 发表于 2020-7-5 09:36
实际上楼主想的太简单了,现实绘图中,会能很多限制条件的。
①先判断有无该图层,无则新建,有则须进一步 ...
确实,初学实践一下还行,实际应用的时候必须考虑各种情况,逻辑思维要好 这种技术含量太低了,无非就是调用CAD的“change”命令,几乎所有的绘图命令都可以用这种方式实现。 在别的网站上转的,学习一下 不错,学习了! 这个看不懂11!!!! 好东西好东西 不错,学习了! 学习了谢谢 学习勒感谢楼主的无私奉献 呵呵 感觉挺好用的 学习下 不错,学习了!
页:
[1]
2