明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2764|回复: 17

help me to create Layers

  [复制链接]
发表于 2011-7-14 20:03 | 显示全部楼层 |阅读模式
Dear All,i want create many layer in lisp

  ;; Layer Name      
  ;; Layer Colour  
  ;; Layer Linetype
  ;; Layer Lineweight
  ;; Plot (or do not plot)
  ;;Layer( lock unlock froze unfrozen)
  ;; Description

;; Group

"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2011-7-14 20:09 | 显示全部楼层
 楼主| 发表于 2011-7-16 14:01 | 显示全部楼层
dear sir,
this not my answer
i want standard layer makers
发表于 2011-7-16 14:38 | 显示全部楼层
发表于 2011-7-16 16:32 | 显示全部楼层
 楼主| 发表于 2011-7-16 17:16 | 显示全部楼层
本帖最后由 sachindkini 于 2011-7-16 17:18 编辑

Dear Sir,
thx for reply
im not searching layer off layer on lisp, i want create standard layer for my company required
im prenatally using template  
example (wall, window, area, )

本帖子中包含更多资源

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

x
发表于 2011-7-16 22:27 | 显示全部楼层
哇,给人的感觉这是一个大工程啊,不知道这些层是一开始就要添加进CAD
,还是根据需要添加,比如说原来没有 "wall" 这个层,当我们开始画 "wall" 时自动添加。
发表于 2011-7-16 22:55 | 显示全部楼层
本帖最后由 Gu_xl 于 2011-7-16 22:57 编辑

回复 sachindkini 的帖子

  1. (defun c:tt ()
  2.   (setq layers (vla-get-layers (vla-get-ActiveDocument (vlax-get-acad-object))))
  3.   (setq layer (VL-CATCH-ALL-APPLY 'vla-Item (list layers "PL-AMENITY")))
  4.   (if (VL-CATCH-ALL-ERROR-P layer) (setq layer (vla-add layers "PL-AMENITY")))
  5.   (vla-put-Description layer "PLINE AMENITY")
  6.   (vla-put-color layer 8)
  7.   (vla-put-linetype layer "Continuous")
  8.   (vla-put-lineweight layer 25)
  9.   (vla-put-Plottable layer :vlax-false)
  10.   .
  11.   .
  12.   .
  13.   )
 楼主| 发表于 2011-7-18 16:05 | 显示全部楼层
回复 Gu_xl 的帖子
  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 -                              ;;
  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                         ;;
  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. )
Dear sir thx for help me nice code
find some code at website but error on this lisp add description no groups are there can u help me


发表于 2011-7-18 16:47 | 显示全部楼层
本帖最后由 Gu_xl 于 2011-7-18 16:52 编辑

回复 sachindkini 的帖子

Your CAD software version ?Above Ver 2005 support property  Description
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-3-29 21:20 , Processed in 0.202754 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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