明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 5079|回复: 25

[源码] 自动建立图层并指定图层名称、颜色、线型 、线宽

[复制链接]
发表于 2022-7-18 17:08:40 | 显示全部楼层 |阅读模式
本帖最后由 tfanghui 于 2022-7-19 14:10 编辑

借鉴明经大神的建图层,自动建立图层 指定图层名称、颜色、线型 、线宽。朋友们可以根据自己工作习惯修改。

本帖子中包含更多资源

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

x

评分

参与人数 1明经币 +1 收起 理由
tigcat + 1 金币一枚送上。

查看全部评分

"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2022-7-26 17:38:53 | 显示全部楼层
  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.   (command "-style" "ZG" "TXT1.shx,HZTXT1.shx" "" "0.7" "" "" "" "N")
  21.   (command "-style" "黑体" "黑体" "" "0.7" "" "" "")
  22.   (command ".layer" "p" "p" "PUB_WINDW" "")
  23.   (setvar "cmdecho" 1)
  24. (princ)
  25. )

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

  58. ;;;自动创建装修常用图层
  59. (defun c:FFG ()
  60.   (setvar "cmdecho" 0)
  61.   (command "layer" "m" "0-TF-天花布置" "c" "2" "" "")
  62.   (command "layer" "m" "0-FURN-平面图" "c" "2" "" "")
  63.   (command "layer" "m" "0-TF-天花灯具布置" "c" "6" "" "")
  64.   (command "layer" "m" "0-TF-天花尺寸标注" "c" "3" "" "")
  65.   (command "layer" "m" "0-DM-地面填充" "c" "251" "" "")
  66.   (command "layer" "m" "0-DM-地坪分割线" "c" "251" "" "")
  67.   (command "layer" "m" "0-DM-门槛线" "c" "251" "" "")
  68.   (command "layer" "m" "0-DM-地面尺寸标注" "c" "3" "" "")
  69.   (command "layer" "m" "0-FURN-平面布置图" "c" "2" "" "")
  70.   (command "layer" "m" "0-FURN-平面尺寸" "c" "2" "" "")
  71.   (command "layer" "m" "0-PM-固定家具" "c" "251" "" "")
  72.   (command "layer" "m" "DOOR" "c" "4" "" "")
  73.   (command "layer" "m" "DOTE"  "c" "1" "" "l" "DOTE" """")
  74.   (command "layer" "m" "DOOR-NAME" "c" "4" "" "")
  75.   (command "layer" "m" "WALL" "c" "42" "" "")
  76.   (command "layer" "m" "大样剖切线" "c" "4" "" "")
  77.   (command "layer" "m" "PUB_WINDW" "c" "7" "" "")
  78.   (command ".layer" "p" "p" "PUB_WINDW" "")
  79.   (command "layer" "m" "A-FURN-绘图层" "c" "2" "" "")
  80.   (command "-style" "ZG" "TXT1.shx,HZTXT1.shx" "" "0.7" "" "" ""  "N")
  81.   (command "-style" "黑体" "黑体" "" "0.7" "" "" "")
  82.   (command ".layer" "p" "p" "PUB_WINDW" "")
  83.   (setvar "cmdecho" 1)
  84. (princ)
  85. )

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


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

  94. ;;通过命令设换到相应图层
  95. (defun c:F1() (setvar "clayer" "A-ELEV-LIN1-立面外轮廓线") (princ))
  96. (defun c:F2() (setvar "clayer" "A-ELEV-LIN2-立面中轮廓线") (princ))
  97. (defun c:F3() (setvar "clayer" "A-ELEV-LIN3-立面细轮廓线") (princ))
  98. (defun c:F4() (setvar "clayer" "A-FURN-绘图层") (princ))
  99. (defun c:F5() (setvar "clayer" "0-PM-固定家具") (princ))
  100. (defun c:FFC() (setvar "clayer" "DOTE") (princ))
  101. (defun c:FFD() (setvar "clayer" "DOOR") (princ))
  102. (defun c:FFW() (setvar "clayer" "WINDOW") (princ))
  103. (defun c:FFJ() (setvar "clayer" "0-总图-建筑红线") (princ))
  104. (defun c:FFX() (setvar "clayer" "0-总图-用地红线") (princ))
  105. (defun c:FW() (setvar "clayer" "WALL") (princ))
  106. (defun c:F0() (setvar "clayer" "0") (princ))

;;;自动创建常用图层
(defun c:FFF ()
  (setvar "cmdecho" 0)
  (command "layer" "m" "DOTE"  "c" "1" "" "l" "DOTE" """")
  (command "layer" "m" "WALL" "c" "42" "" "")
  (command "layer" "m" "A-ELEV-LIN1-立面外轮廓线" "c" "42" "" "")
  (command "layer" "m" "A-ELEV-LIN2-立面中轮廓线" "c" "2" "" "")
  (command "layer" "m" "A-ELEV-LIN3-立面细轮廓线" "c" "153" "" "")
  (command "layer" "m" "A-ELEV_OTHER-立面配景" "c" "153" "" "")
  (command "layer" "m" "0-PM-固定家具" "c" "251" "" "")
  (command "layer" "m" "0-PM-建筑面积计算" "c" "6" "" "")
  (command "layer" "m" "DOOR" "c" "4" "" "")
  (command "layer" "m" "DOOR-NAME" "c" "5" "" "")
  (command "layer" "m" "大样剖切线" "c" "4" "" "")
  (command "layer" "m" "WALL" "c" "42" "" "")
  (command "layer" "m" "A-FURN-绘图层" "c" "2" "" "")
  (command "layer" "m" "UB_WINDW" "c" "7" "" "")
  (command ".layer" "p" "p" "UB_WINDW" "")
  (command "layer" "m" "A-FURN-绘图层" "c" "2" "" "")
  (command "-style" "ZG" "TXT1.shx,HZTXT1.shx" "" "0.7" "" "" "" "N")
  (command "-style" "黑体" "黑体" "" "0.7" "" "" "")
  (command ".layer" "p" "p" "UB_WINDW" "")
  (setvar "cmdecho" 1)
(princ)
)

;;;自动创建常用总图图层
(defun c:FFA ()
  (setvar "cmdecho" 0)
  (command "layer" "m" "0-总图-建筑红线" "c" "1" "" "l" "HANTOM" """")
  (command "layer" "m" "0-总图-用地红线"  "c" "6" "" "l" "DOTE" """")
  (command "layer" "m" "DOTE"  "c" "1" "" "l" "DOTE" """")
  (command "layer" "m" "WALL" "c" "42" "" "")
  (command "layer" "m" "0-总图-道路红线" "c" "2" "" "")
  (command "layer" "m" "0-总图-道路边线" "c" "3" "" "")
  (command "layer" "m" "0-总图-道路中心线" "c" "1" "" "l" "CENTER" """")
  (command "layer" "m" "0-总图-建筑外边线" "c" "42" "" "")
  (command "layer" "m" "0-总图-建筑可视线" "c" "2" "" "")
  (command "layer" "m" "0-总图-已建建筑外边线" "c" "190" "" "")
  (command "layer" "m" "0-总图-围墙线" "c" "221" "" "")
  (command "layer" "m" "0-总图-构筑物" "c" "6" "" "")
  (command "layer" "m" "0-总图-园林植物" "c" "251" "" "")
  (command "layer" "m" "0-总图-表格线" "c" "3" "" "")
  (command "layer" "m" "0-总图-园林布置" "c" "2" "" "")  
  (command "layer" "m" "0-总图-摩托车位" "c" "6" "" "")  
  (command "layer" "m" "0-总图-非机车位" "c" "6" "" "")  
  (command "layer" "m" "0-总图-绿地面积" "c" "6" "" "")  
  (command "layer" "m" "0-总图-绿化树" "c" "251" "" "")   
  (command "layer" "m" "0-总图-小汽车停车位" "c" "6" "" "")
  (command "layer" "m" "UB_WINDW" "c" "7" "" "")
  (command ".layer" "p" "p" "UB_WINDW" "")
  (command "layer" "m" "A-FURN-绘图层" "c" "2" "" "")
  (command "-style" "ZG" "TXT1.shx,HZTXT1.shx" "" "0.7" "" "" ""  "N")
  (command "-style" "黑体" "黑体" "" "0.7" "" "" "")
  (command ".layer" "p" "p" "UB_WINDW" "")
  (setvar "cmdecho" 1)
(princ)
)

;;;自动创建装修常用图层
(defun c:FFG ()
  (setvar "cmdecho" 0)
  (command "layer" "m" "0-TF-天花布置" "c" "2" "" "")
  (command "layer" "m" "0-FURN-平面图" "c" "2" "" "")
  (command "layer" "m" "0-TF-天花灯具布置" "c" "6" "" "")
  (command "layer" "m" "0-TF-天花尺寸标注" "c" "3" "" "")
  (command "layer" "m" "0-DM-地面填充" "c" "251" "" "")
  (command "layer" "m" "0-DM-地坪分割线" "c" "251" "" "")
  (command "layer" "m" "0-DM-门槛线" "c" "251" "" "")
  (command "layer" "m" "0-DM-地面尺寸标注" "c" "3" "" "")
  (command "layer" "m" "0-FURN-平面布置图" "c" "2" "" "")
  (command "layer" "m" "0-FURN-平面尺寸" "c" "2" "" "")
  (command "layer" "m" "0-PM-固定家具" "c" "251" "" "")
  (command "layer" "m" "DOOR" "c" "4" "" "")
  (command "layer" "m" "DOTE"  "c" "1" "" "l" "DOTE" """")
  (command "layer" "m" "DOOR-NAME" "c" "4" "" "")
  (command "layer" "m" "WALL" "c" "42" "" "")
  (command "layer" "m" "大样剖切线" "c" "4" "" "")
  (command "layer" "m" "UB_WINDW" "c" "7" "" "")
  (command ".layer" "p" "p" "UB_WINDW" "")
  (command "layer" "m" "A-FURN-绘图层" "c" "2" "" "")
  (command "-style" "ZG" "TXT1.shx,HZTXT1.shx" "" "0.7" "" "" ""  "N")
  (command "-style" "黑体" "黑体" "" "0.7" "" "" "")
  (command ".layer" "p" "p" "UB_WINDW" "")
  (setvar "cmdecho" 1)
(princ)
)

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


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

;;通过命令设换到相应图层
(defun c:F1() (setvar "clayer" "A-ELEV-LIN1-立面外轮廓线") (princ))
(defun c:F2() (setvar "clayer" "A-ELEV-LIN2-立面中轮廓线") (princ))
(defun c:F3() (setvar "clayer" "A-ELEV-LIN3-立面细轮廓线") (princ))
(defun c:F4() (setvar "clayer" "A-FURN-绘图层") (princ))
(defun c:F5() (setvar "clayer" "0-PM-固定家具") (princ))
(defun c:FFC() (setvar "clayer" "DOTE") (princ))
(defun c:FFD() (setvar "clayer" "DOOR") (princ))
(defun c:FFW() (setvar "clayer" "WINDOW") (princ))
(defun c:FFJ() (setvar "clayer" "0-总图-建筑红线") (princ))
(defun c:FFX() (setvar "clayer" "0-总图-用地红线") (princ))
(defun c:FW() (setvar "clayer" "WALL") (princ))
(defun c:F0() (setvar "clayer" "0") (princ))
回复 支持 2 反对 0

使用道具 举报

发表于 2022-10-3 23:08:17 | 显示全部楼层
本帖最后由 sachindkini 于 2022-10-3 23:09 编辑

  1. (defun c:MakeLayers nil (vl-load-com)  
  2.   ;; © Lee Mac 2010

  3.   ;;----------------------------------------------------------------------------------------------;;
  4.   ;; Specifications:                                                                              ;;
  5.   ;;----------------------------------------------------------------------------------------------;;
  6.   ;; Description         Data Type       Remarks                                                  ;;
  7.   ;;----------------------------------------------------------------------------------------------;;
  8.   ;; Layer Name          STRING          Only standard chars allowed.                             ;;
  9.   ;; Layer Colour        INTEGER         may be nil, -ve for Layer Off, Colour < 256              ;;
  10.   ;; Layer Linetype      STRING          may be nil, If not loaded, CONTINUOUS.                   ;;
  11.   ;; Layer Lineweight    REAL            may be nil, negative=Default, otherwise 0 <= x <= 2.11   ;;
  12.   ;; Plot?               BOOLEAN         T = Plot Layer, nil otherwise                            ;;
  13.   ;; Bit Flag            INTEGER         0=None, 1=Frozen, 2=Frozen in VP, 4=Locked               ;;
  14.   ;; Description         STRING          may be nil for no description                            ;;
  15.   ;;----------------------------------------------------------------------------------------------;;
  16.   ;; Function will print list detailing any unsuccesful layers                                    ;;
  17.   ;;----------------------------------------------------------------------------------------------;;
  18.   
  19.   (
  20.     (lambda ( lst )
  21.       (mapcar 'print
  22.         (vl-remove-if 'cdr
  23.           (mapcar
  24.             (function
  25.               (lambda ( x )
  26.                 (and (caddr x) (LM:LoadLinetype (caddr x))) (cons (car x) (apply 'MakeLayer x))
  27.               )
  28.             )
  29.             lst
  30.           )
  31.         )
  32.       )
  33.     )
  34.    '(
  35.     ;  Name                 Colour   Linetype    Lineweight Plot? Bitflag  Description
  36.     ( "EL_COMPONENTS"            7  "CONTINUOUS"     -3       T      0      nil  )
  37.     ( "EL_CONSTR_COMP"           1  "CONTINUOUS"     -3       T      0      nil  )
  38.     ( "EL_FITTINGS"              4  "CONTINUOUS"     -3       T      0      nil  )
  39.     ( "EL_LABEL"                 1  "CONTINUOUS"     -3       T      0      nil  )
  40.     ( "EL_LABEL_TXT"           252  "CONTINUOUS"     -3       T      0      nil  )
  41.     ( "EL_TERMINALS"             1  "CONTINUOUS"     -3       T      0      nil  )
  42.     ( "EL_TERMINALS_PE"         24  "CONTINUOUS"     -3       T      0      nil  )
  43.     ( "EL_TERMINALS_TXT"       252  "CONTINUOUS"     -3       T      0      nil  )
  44.     ( "EL_TXT"                 252  "CONTINUOUS"     -3       T      0      nil  )
  45.     ( "EL_WIRES"               252  "CONTINUOUS"     -3       T      0      nil  )
  46.     ( "GE_ANNOTATION"            7  "CONTINUOUS"     -3       T      0      nil  )
  47.     ( "GE_LABEL"                10  "CONTINUOUS"     -3       T      0      nil  )
  48.     ( "GE_LABEL_TEXT"          253  "CONTINUOUS"     -3       T      0      nil  )
  49.     ( "GE_TXT_LANGUAGE_DU"     252  "CONTINUOUS"     -3       T      0      nil  )
  50.     ( "GE_TXT_LANGUAGE_EN"     252  "CONTINUOUS"     -3       T      0      nil  )
  51.     ( "GE_TXT_LANGUAGE_FR"     252  "CONTINUOUS"     -3       T      0      nil  )
  52.     ( "GE_TXT_LANGUAGE_GE"     252  "CONTINUOUS"     -3       T      0      nil  )
  53.     ( "LA_HEADER_FRAME"          7  "CONTINUOUS"     -3       T      0      nil  )
  54.     ( "LA_HEADER_TXT"            7  "CONTINUOUS"     -3       T      0      nil  )
  55.     ( "LA_MATLIST"             254  "CONTINUOUS"     -3       T      0      nil  )
  56.     ( "LA_MATLIST_FRAME"       254  "CONTINUOUS"     -3       T      0      nil  )
  57.     ( "LA_MATLIST_POS"         254  "CONTINUOUS"     -3       T      0      nil  )
  58.     ( "LA_MATLIST_TXT"         252  "CONTINUOUS"     -3       T      0      nil  )
  59.     ( "LA_TITLE_FRAME"           7  "CONTINUOUS"     -3       T      0      nil  )
  60.     ( "LA_TITLE_LOGO"           10  "CONTINUOUS"     -3       T      0      nil  )
  61.     ( "LA_TITLE_LOGO_TXT"        7  "CONTINUOUS"     -3       T      0      nil  )
  62.     ( "LA_TITLE_TXT"             7  "CONTINUOUS"     -3       T      0      nil  )
  63.     ( "LA_VIEWPORTS"           230  "CONTINUOUS"     -3      nil     0      nil  )
  64.     ( "PN_ACCESSORIES"          30  "CONTINUOUS"     -3       T      0      nil  )
  65.     ( "PN_ACTUATORS"           160  "CONTINUOUS"     -3       T      0      nil  )
  66.     ( "PN_AIR_LINE_EQUIPMENT"   40  "CONTINUOUS"     -3       T      0      nil  )
  67.     ( "PN_BRACKET_MOUNTING"      1  "ACAD_ISO12W100" -3       T      0      nil  )
  68.     ( "PN_CABINET"               8  "CONTINUOUS"     -3       T      0      nil  )
  69.     ( "PN_CABINET_DIM"           8  "CONTINUOUS"     -3       T      0      nil  )
  70.     ( "PN_COMPONENTS"            7  "CONTINUOUS"     -3       T      0      nil  )
  71.     ( "PN_CONDUCTS"              3  "CONTINUOUS"     -3       T      0      nil  )
  72.     ( "PN_CONSTR_COMP"           2  "CONTINUOUS"     -3       T      0      nil  )
  73.     ( "PN_DRAIN"                 3  "HIDDEN"         -3       T      0      nil  )
  74.     ( "PN_EXHAUST"             104  "CONTINUOUS"     -3       T      0      nil  )
  75.     ( "PN_FITTINGS"             30  "CONTINUOUS"     -3       T      0      nil  )
  76.     ( "PN_IDENTIFICATION"        4  "CONTINUOUS"     -3       T      0      nil  )
  77.     ( "PN_PILOT_SUPPLY"          3  "HIDDEN"         -3       T      0      nil  )
  78.     ( "PN_PORT_NUMBERS"          8  "CONTINUOUS"     -3       T      0      nil  )
  79.     ( "PN_PRESSURE_SWITCHES"   200  "CONTINUOUS"     -3       T      0      nil  )
  80.     ( "PN_PROPORTIONAL_VALVES" 226  "CONTINUOUS"     -3       T      0      nil  )
  81.     ( "PN_SECTIONS"              3  "CONTINUOUS"     -3       T      0      nil  )
  82.     ( "PN_SUB-BASES"             8  "ACAD_ISO12W100" -3       T      0      nil  )
  83.     ( "PN_SUB-BASE_CONDUCTS"     2  "CONTINUOUS"     -3       T      0      nil  )
  84.     ( "PN_SUPPLY"                3  "CONTINUOUS"     -3       T      0      nil  )
  85.     ( "PN_TXT"                   3  "CONTINUOUS"     -3       T      0      nil  )
  86.     ( "PN_VACUUM"               60  "CONTINUOUS"     -3       T      0      nil  )
  87.     ( "PN_VALVES"              240  "CONTINUOUS"     -3       T      0      nil  )
  88.     ( "PN_VALVES_OVERRIDE"       1  "CONTINUOUS"     -3       T      0      nil  )
  89.     )
  90.   )
  91.   (princ)
  92. )

  93. (defun MakeLayer ( name colour linetype lineweight willplot bitflag description )
  94.   ;; &#169; Lee Mac 2010
  95.   (or (tblsearch "LAYER" name)
  96.     (entmake
  97.       (append
  98.         (list
  99.           (cons 0 "LAYER")
  100.           (cons 100 "AcDbSymbolTableRecord")
  101.           (cons 100 "AcDbLayerTableRecord")
  102.           (cons 2  name)
  103.           (cons 70 bitflag)
  104.           (cons 290 (if willplot 1 0))
  105.           (cons 6
  106.             (if (and linetype (tblsearch "LTYPE" linetype))
  107.               linetype "CONTINUOUS"
  108.             )
  109.           )
  110.           (cons 62 (if (and colour (< 0 (abs colour) 256)) colour 7))
  111.           (cons 370
  112.             (if (minusp lineweight) -3
  113.               (fix
  114.                 (* 100
  115.                   (if (and lineweight (<= 0.0 lineweight 2.11)) lineweight 0.0)
  116.                 )
  117.               )
  118.             )
  119.           )
  120.         )
  121.         (if description
  122.           (list
  123.             (list -3
  124.               (list "AcAecLayerStandard" (cons 1000 "") (cons 1000 description))
  125.             )
  126.           )
  127.         )
  128.       )
  129.     )
  130.   )
  131. )

  132. ;;--------------------=={ Load Linetype }==-------------------;;
  133. ;;                                                            ;;
  134. ;;  Attempts to load a specified linetype from any linetype   ;;
  135. ;;  definition files (.lin) found in the ACAD Support Path    ;;
  136. ;;------------------------------------------------------------;;
  137. ;;  Author: Lee Mac, Copyright &#169; 2011 - www.lee-mac.com       ;;
  138. ;;------------------------------------------------------------;;
  139. ;;  Arguments:                                                ;;
  140. ;;  lt - name of linetype to load                             ;;
  141. ;;------------------------------------------------------------;;
  142. ;;  Returns:  T if linetype loaded successfully, else nil     ;;
  143. ;;------------------------------------------------------------;;

  144. (defun LM:LoadLinetype ( lt ) (vl-load-com)
  145.   ;; &#169; Lee Mac 2010
  146.   
  147.   (cond
  148.     ( (tblsearch "LTYPE" lt) )
  149.     ( (progn
  150.         (or acdoc (setq acdoc (vla-get-ActiveDocument (setq acapp (vlax-get-acad-object)))))
  151.         (or aclts (setq aclts (vla-get-Linetypes acdoc)))

  152.         (vl-some
  153.           (function
  154.             (lambda ( file )
  155.               (vl-catch-all-apply 'vla-load (list aclts lt file))
  156.               (and (tblsearch "LTYPE" lt))
  157.             )
  158.           )
  159.           (setq *LineTypeDefs*
  160.             (cond
  161.               ( *LineTypeDefs* )
  162.               (
  163.                 (apply 'append
  164.                   (mapcar '(lambda ( directory ) (vl-directory-files directory "*.lin" 1))
  165.                     (LM:str->lst
  166.                       (vla-get-SupportPath (vla-get-Files (vla-get-Preferences acapp))) ";"
  167.                     )
  168.                   )
  169.                 )
  170.               )
  171.             )
  172.           )
  173.         )
  174.       )
  175.     )
  176.   )  
  177. )

  178. ;;-------------------=={ String to List }==-------------------;;
  179. ;;                                                            ;;
  180. ;;  Separates a string into a list of strings using a         ;;
  181. ;;  specified delimiter string                                ;;
  182. ;;------------------------------------------------------------;;
  183. ;;  Author: Lee Mac, Copyright &#169; 2011 - www.lee-mac.com       ;;
  184. ;;------------------------------------------------------------;;
  185. ;;  Arguments:                                                ;;
  186. ;;  str - string to process                                   ;;
  187. ;;  del - delimiter by which to separate the string           ;;
  188. ;;------------------------------------------------------------;;
  189. ;;  Returns:  A list of strings                               ;;
  190. ;;------------------------------------------------------------;;

  191. (defun LM:str->lst ( str del / pos )
  192.   ;; &#169; Lee Mac 2010
  193.   (if (setq pos (vl-string-search del str))
  194.     (vl-remove "" (cons (substr str 1 pos) (LM:str->lst (substr str (+ pos 1 (strlen del))) del)))
  195.     (list str)
  196.   )
  197. )

点评

优秀  发表于 2022-11-1 16:54
好高深  发表于 2022-10-3 23:41
发表于 2022-7-18 17:56:06 | 显示全部楼层
谢谢分享,支持楼主一下。
发表于 2022-7-19 01:49:01 | 显示全部楼层
楼主,你可以看一下这个哟,也是很强大呢~
可以强制更新图层信息.
http://bbs.mjtd.com/thread-111246-1-1.html
发表于 2022-7-19 08:44:03 | 显示全部楼层
谢谢分享,支持
 楼主| 发表于 2022-7-20 10:10:25 | 显示全部楼层
丶俗人 发表于 2022-7-19 01:49
楼主,你可以看一下这个哟,也是很强大呢~
可以强制更新图层信息.
http://bbs.mjtd.com/thread-111246-1-1. ...

他这很强大,我试了一下,但是多建几个图层就会出现错误,不知道是什么原因。
发表于 2022-7-25 00:42:04 | 显示全部楼层
tfanghui 发表于 2022-7-20 10:10
他这很强大,我试了一下,但是多建几个图层就会出现错误,不知道是什么原因。

应该不会呀.我都是一次性创建五六十个图层.
应该是你图层的代码哪里出错了.
发表于 2022-7-25 08:44:20 来自手机 | 显示全部楼层
感谢分享,挺好的程序
发表于 2022-7-25 15:45:14 | 显示全部楼层
感谢分享,挺好的程序
发表于 2022-7-25 16:55:50 来自手机 | 显示全部楼层
下来试试,谢谢大佬分手
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-25 06:32 , Processed in 0.209313 second(s), 29 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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