明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 4015|回复: 18

数字切换图层

  [复制链接]
发表于 2022-2-17 19:58:03 | 显示全部楼层 |阅读模式
把选中的对象改到相应的图层上,无选中情况下,则图层切换

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x

评分

参与人数 3明经币 +3 收起 理由
a405692168 + 1 很给力!
tfanghui + 1 很给力!
tigcat + 1 很给力!

查看全部评分

发表于 2022-6-24 15:22:32 | 显示全部楼层
  1. ;;;自动创建常用图层
  2. (defun c:FFF ()
  3.   (setvar "cmdecho" 0)
  4.   (command "layer" "m" "DOTE"  "c" "1" "" "l" "DOTE" """")
  5.   (command "layer" "m" "WALL" "c" "42" "" "")
  6.   (command "layer" "m" "A-ELEV-LIN1-立面外轮廓线" "c" "42" "" "")
  7.   (command "layer" "m" "A-ELEV-LIN2-立面中轮廓线" "c" "2" "" "")
  8.   (command "layer" "m" "A-ELEV-LIN3-立面细轮廓线" "c" "153" "" "")
  9.   (command "layer" "m" "A-ELEV_OTHER-立面配景" "c" "153" "" "")
  10.   (command "layer" "m" "0-PM-固定家具" "c" "251" "" "")
  11.   (command "layer" "m" "0-PM-建筑面积计算" "c" "6" "" "")
  12.   (command "layer" "m" "DOOR" "c" "4" "" "")
  13.   (command "layer" "m" "DOOR-NAME" "c" "5" "" "")
  14.   (command "layer" "m" "大样剖切线" "c" "4" "" "")
  15.   (command "layer" "m" "WALL" "c" "42" "" "")
  16.   (command "layer" "m" "A-FURN-绘图层" "c" "2" "" "")
  17.   (command "layer" "m" "PUB_WINDW" "c" "7" "" "")
  18.   (command ".layer" "p" "p" "PUB_WINDW" "")
  19.   (command "layer" "m" "A-FURN-绘图层" "c" "2" "" "")
  20.   (setvar "cmdecho" 1)
  21. (princ)
  22. )

  23. ;;;自动创建常用总图图层
  24. (defun c:FFA ()
  25.   (setvar "cmdecho" 0)
  26.   (command "layer" "m" "0-总图-建筑红线" "c" "1" "" "l" "PHANTOM" """")
  27.   (command "layer" "m" "0-总图-红地红线"  "c" "6" "" "l" "DOTE" """")
  28.   (command "layer" "m" "DOTE"  "c" "1" "" "l" "DOTE" """")
  29.   (command "layer" "m" "WALL" "c" "42" "" "")
  30.   (command "layer" "m" "0-总图-道路红线" "c" "2" "" "")
  31.   (command "layer" "m" "0-总图-道路边线" "c" "3" "" "")
  32.   (command "layer" "m" "0-总图-道路中心线" "c" "1" "" "l" "CENTER" """")
  33.   (command "layer" "m" "0-总图-建筑外边线" "c" "42" "" "")
  34.   (command "layer" "m" "0-总图-建筑可视线" "c" "2" "" "")
  35.   (command "layer" "m" "0-总图-已建建筑外边线" "c" "190" "" "")
  36.   (command "layer" "m" "0-总图-围墙线" "c" "221" "" "")
  37.   (command "layer" "m" "0-总图-构筑物" "c" "6" "" "")
  38.   (command "layer" "m" "0-总图-园林植物" "c" "251" "" "")
  39.   (command "layer" "m" "0-总图-表格线" "c" "3" "" "")
  40.   (command "layer" "m" "0-总图-园林布置" "c" "2" "" "")  
  41.   (command "layer" "m" "0-总图-摩托车位" "c" "6" "" "")  
  42.   (command "layer" "m" "0-总图-非机车位" "c" "6" "" "")  
  43.   (command "layer" "m" "0-总图-绿地面积" "c" "6" "" "")  
  44.   (command "layer" "m" "0-总图-绿化树" "c" "251" "" "")   
  45.   (command "layer" "m" "0-总图-小汽车停车位" "c" "6" "" "")
  46.   (command "layer" "m" "PUB_WINDW" "c" "7" "" "")
  47.   (command ".layer" "p" "p" "PUB_WINDW" "")
  48.   (command "layer" "m" "A-FURN-绘图层" "c" "2" "" "")
  49.   (setvar "cmdecho" 1)
  50. (princ)
  51. )

  52. ;;;自动创建装修常用图层
  53. (defun c:FFG ()
  54.   (setvar "cmdecho" 0)
  55.   (command "layer" "m" "0-TF-天花布置" "c" "2" "" "")
  56.   (command "layer" "m" "0-FURN-平面图" "c" "2" "" "")
  57.   (command "layer" "m" "0-TF-天花灯具布置" "c" "6" "" "")
  58.   (command "layer" "m" "0-TF-天花尺寸标注" "c" "3" "" "")
  59.   (command "layer" "m" "0-DM-地面填充" "c" "251" "" "")
  60.   (command "layer" "m" "0-DM-地坪分割线" "c" "251" "" "")
  61.   (command "layer" "m" "0-DM-门槛线" "c" "251" "" "")
  62.   (command "layer" "m" "0-DM-地面尺寸标注" "c" "3" "" "")
  63.   (command "layer" "m" "0-FURN-平面布置图" "c" "2" "" "")
  64.   (command "layer" "m" "0-FURN-平面尺寸" "c" "2" "" "")
  65.   (command "layer" "m" "0-PM-固定家具" "c" "251" "" "")
  66.   (command "layer" "m" "DOOR" "c" "4" "" "")
  67.   (command "layer" "m" "DOTE"  "c" "1" "" "l" "DOTE" """")
  68.   (command "layer" "m" "DOOR-NAME" "c" "4" "" "")
  69.   (command "layer" "m" "WALL" "c" "42" "" "")
  70.   (command "layer" "m" "大样剖切线" "c" "4" "" "")
  71.   (command "layer" "m" "PUB_WINDW" "c" "7" "" "")
  72.   (command ".layer" "p" "p" "PUB_WINDW" "")
  73.   (command "layer" "m" "A-FURN-绘图层" "c" "2" "" "")
  74.   (setvar "cmdecho" 1)
  75. (princ)
  76. )

  77. ;;通过命令设换到相应天花图层
  78. (defun c:T1() (setvar "clayer" "0-TF-天花布置") (princ))
  79. (defun c:T2() (setvar "clayer" "0-TF-天花尺寸标注") (princ))
  80. (defun c:T3() (setvar "clayer" "0-TF-天花灯具布置") (princ))


  81. ;;通过命令设换到相应地面图层
  82. (defun c:D1() (setvar "clayer" "0-DM-地面填充") (princ))
  83. (defun c:D2() (setvar "clayer" "0-DM-地面尺寸标注") (princ))
  84. (defun c:D3() (setvar "clayer" "0-DM-地坪分割线") (princ))

  85. ;;通过命令设换到相应图层
  86. (defun c:F1() (setvar "clayer" "A-ELEV-LIN1-立面外轮廓线") (princ))
  87. (defun c:F2() (setvar "clayer" "A-ELEV-LIN2-立面中轮廓线") (princ))
  88. (defun c:F3() (setvar "clayer" "A-ELEV-LIN3-立面细轮廓线") (princ))
  89. (defun c:F4() (setvar "clayer" "A-FURN-绘图层") (princ))
  90. (defun c:F5() (setvar "clayer" "0-PM-固定家具") (princ))
  91. (defun c:FFC() (setvar "clayer" "DOTE") (princ))
  92. (defun c:FFD() (setvar "clayer" "DOOR") (princ))
  93. (defun c:FFW() (setvar "clayer" "WINDOW") (princ))
  94. (defun c:FW() (setvar "clayer" "WALL") (princ))
  95. (defun c:F0() (setvar "clayer" "0") (princ))

  96. ;;;定义各视图方向
  97. (defun c:w`()(command "vpoint" "-1,-2,1") (princ))
  98. (defun c:w1()(command "-view" "swiso")    (princ))
  99. (defun c:w2()(command "-view" "seiso")    (princ))
  100. (defun c:w3()(command "-view" "neiso")    (princ))
  101. (defun c:w4()(command "-view" "nwiso")    (princ))
  102. (defun c:w5()(command "-view" "top")      (princ))
  103. (defun c:w6()(command "-view" "front")    (princ))
  104. (defun c:w7()(command "-view" "left")     (princ))
  105. (defun c:w8()(command "-view" "right")    (princ))
回复 支持 1 反对 0

使用道具 举报

发表于 2024-4-25 22:42:41 | 显示全部楼层
panliang9 发表于 2022-2-18 08:48
不错,这个可以扩展一下。
1、在选中对象的前提下下,输入命令则将对象切换到该数字图层。
2、没有选中对 ...
  1. ;;加载线型
  2. (defun JZXX ()
  3.   (or (TBLSEARCH "LTYPE" "CENTER,DASHED,FENCELINE1,FENCELINE2,PHANTOM")    ;搜索是否存在线型
  4.     (vl-catch-all-apply
  5.       'vla-load
  6.       (list (vla-get-Linetypes
  7.             (vla-get-ActiveDocument (vlax-get-acad-object))
  8.           )
  9.           "CENTER,DASHED,FENCELINE1,FENCELINE2,PHANTOM"
  10.           (findfile "acadiso.lin")
  11.       )                                                                    ;不存在则加载线型
  12.     )
  13.   )
  14. )

  15. (defun li-xjtc (cm ys xx xk dy / ss lts )
  16.     (JZXX) ;加载线型
  17.     (Princ "\<<<<图层切换程序>>>>")
  18.     (setvar "cmdecho" 0)
  19.     (if        (= (tblsearch "layer" cm) nil)
  20.       (entmake
  21.         (list
  22.                       '(0 . "LAYER")
  23.                       '(100 . "AcDbSymbolTableRecord")
  24.                       '(100 . "AcDbLayerTableRecord")
  25.                       '(70 . 0)        ;图层状态
  26.                       (cons 2 cm)      ;图层名称
  27.                       (cons 62 ys)     ;图层颜色
  28.                       (cons 6 xx)      ;图层线型
  29.                       (cons 370 xk)    ;图层线宽:100=1, 15=0.15, 18=0.18, -3=默认
  30.                       (cons 290 dy)    ;0-不打印,1-打印
  31.         )
  32.       )
  33.     )
  34.     (setq ss (ssget))
  35.     (if (= ss nil)
  36.       (setvar "clayer" cm)                                                 ;没有对象就切换至指定图层
  37.       (command "chprop" ss "" "la" cm "c" "bylayer" "lt" "bylayer" "")     ;有对象就将对象改至指定图层
  38.     )
  39.     (princ)
  40. )

  41. ;;;主程序
  42. (defun c:00 (/) (li-xjtc "0" 7 "continuous" -3 1))              ;切换至 "0" 图层
  43. (defun c:01 (/) (li-xjtc "01-DIM" 3 "continuous" 18 1))         ;切换至 "01-DIM" 图层
  44. (defun c:02 (/) (li-xjtc "02-TXT" 7 "continuous" -3 1))         ;切换至 "02-TXT" 图层
  45. (defun c:03 (/) (li-xjtc "03-Center" 1 "CENTER" 15 1))          ;切换至 "03-Center" 图层
  46. (defun c:04 (/) (li-xjtc "04-Hidden" 8 "DASHED" -3 1))          ;切换至 "04-Hidden" 图层
  47. (defun c:05 (/) (li-xjtc "05-Hatch" 2 "continuous" -3 1))       ;切换至 "05-Hatch" 图层
发表于 2022-2-18 08:48:21 | 显示全部楼层
不错,这个可以扩展一下。
1、在选中对象的前提下下,输入命令则将对象切换到该数字图层。
2、没有选中对象的前提下,则切换到该图层。
3、如果没有该图层,则自动建立该图层。
发表于 2022-2-18 10:19:16 | 显示全部楼层
建筑行业,除了缺省必须的0层,其他的图层几乎没有这种以整数命名的。
发表于 2022-3-27 15:21:08 | 显示全部楼层
e2002 发表于 2022-2-18 10:19
建筑行业,除了缺省必须的0层,其他的图层几乎没有这种以整数命名的。

只建筑行业用cad?
发表于 2022-6-7 20:04:38 | 显示全部楼层
感谢大神分享感谢大神分享
发表于 2022-6-15 11:56:06 | 显示全部楼层
gzcsun 发表于 2022-3-27 15:21
只建筑行业用cad?

可以改图层名吧。
发表于 2022-6-24 15:24:35 | 显示全部楼层
可以参考一下
发表于 2022-7-19 13:36:21 | 显示全部楼层
很好用感谢!!!!
发表于 2022-8-11 23:08:14 | 显示全部楼层
panliang9 发表于 2022-2-18 08:48
不错,这个可以扩展一下。
1、在选中对象的前提下下,输入命令则将对象切换到该数字图层。
2、没有选中对 ...

前辈,这个功能做写出来了吗
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-25 05:01 , Processed in 0.191665 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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