liexol 发表于 2006-9-24 17:26:00

自动建图层lsp

(DEFUN C:TC ()<BR>&nbsp; (COMMAND "LAYER" "M" "base" "C" "8" "" "")<BR>&nbsp; (COMMAND "LAYER" "M" "Cp" "C" "214" "" "")<BR>&nbsp; (COMMAND "LAYER" "M" "d1b" "C" "21" "" "")<BR>&nbsp; (COMMAND "LAYER" "M" "D01A" "C" "1" "" "")<BR>&nbsp; (COMMAND "LAYER" "M" "D02A" "C" "5" "" "")<BR>&nbsp; (COMMAND "LAYER" "M" "D03A" "C" "6" "" "")<BR>&nbsp; (COMMAND "LAYER" "M" "DD" "C" "150" "" "")<BR>&nbsp; (COMMAND "LAYER" "M" "S01A" "C" "3" "" "")<BR>&nbsp; (COMMAND "LAYER" "M" "S1B" "C" "62" "" "")<BR>&nbsp; (COMMAND "LAYER" "M" "SB" "C" "112" "" "")<BR>&nbsp; (COMMAND "LAYER" "M" "S02A" "C" "74" "" "")<BR>&nbsp; (COMMAND "LAYER" "M" "P01A" "C" "2" "" "")<BR>&nbsp; (COMMAND "LAYER" "M" "P02A" "C" "201" "" "")<BR>&nbsp; (COMMAND "LAYER" "M" "P03A" "C" "75" "" "")<BR>&nbsp; (COMMAND "LAYER" "M" "P04A" "C" "30" "" "")<BR>&nbsp; (COMMAND "LAYER" "M" "DIM" "C" "4" "" "")<BR>&nbsp; (COMMAND "LAYER" "M" "yb" "C" "171" "" "")<BR>&nbsp; (COMMAND "LAYER" "M" "zm" "C" "240" "" "")<BR>&nbsp; (COMMAND "LAYER" "M" "tk" "C" "141" "" "")<BR>&nbsp; (COMMAND "LAYER" "M" "DB" "C" "202" "" "")<BR>&nbsp; (COMMAND "LAYER" "M" "p1b" "C" "54" "" "")<BR>&nbsp; (COMMAND "CLAYER" "0")<BR>)

pleasehelp 发表于 2006-9-26 22:53:00

最后一行是不是应该是(setvar "clayer" 0)啊?

无痕 发表于 2006-9-27 23:14:00

<P>用command也可以的</P>

honxj 发表于 2006-11-4 21:56:00

谢谢分享!

chengzhang 发表于 2006-11-5 18:17:00

其实用脚本也是非常方便的

Dallas_whu 发表于 2006-11-5 20:12:00

;;;根据提供的列表建立图层及对应线型<br>(DEFUN C:NLAYS (/&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LAYER_LIST&nbsp;&nbsp; &nbsp;&nbsp; LAYER_NUM&nbsp;&nbsp;&nbsp; I<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;LAYER&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LAYER_NAME&nbsp;&nbsp; &nbsp;&nbsp; LAYER_COLOR&nbsp; CHK_LAYER<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<br>&nbsp; ;;图层列表<br>&nbsp; (SETQ&nbsp;&nbsp; &nbsp;LAYER_LIST<br>&nbsp;&nbsp; &nbsp; (LIST<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; '("图框标签" 8)&nbsp;&nbsp; &nbsp;'("框架外形" 64)<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; '("标高标注" 251)&nbsp;&nbsp; &nbsp;'("框架标注" 6)<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; '("钢筋编号" 3)&nbsp;&nbsp; &nbsp;'("梁柱钢筋" 1)<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; '("图形名称" 7)&nbsp;&nbsp; &nbsp;'("文字说明" 7)<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; '("埋铁布置" 5)&nbsp;&nbsp; &nbsp;'("填充图案" 91)<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; '("辅助线条" 2)&nbsp;&nbsp; &nbsp;'("材料表格" 7)<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; '("详图标注" 3)&nbsp;&nbsp; &nbsp;'("其它图层" 7)<br>&nbsp;&nbsp; &nbsp;&nbsp; )<br>&nbsp; )<br>&nbsp; (SETQ LAYER_NUM (LENGTH LAYER_LIST))<br>&nbsp; (SETQ I 0)<br>&nbsp; (REPEAT LAYER_NUM<br>&nbsp;&nbsp;&nbsp; (SETQ LAYER (NTH I LAYER_LIST))<br>&nbsp;&nbsp;&nbsp; (SETQ LAYER_NAME&nbsp; (CAR LAYER)<br>&nbsp;&nbsp; &nbsp;&nbsp; LAYER_COLOR (CADR LAYER)<br>&nbsp;&nbsp;&nbsp; )<br>&nbsp;&nbsp;&nbsp; (SETQ CHK_LAYER (TBLSEARCH "LAYER" LAYER_NAME))<br>&nbsp;&nbsp;&nbsp; (IF&nbsp;&nbsp; &nbsp;(= CHK_LAYER NIL)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (PROGN<br>&nbsp;&nbsp; &nbsp;(ENTMAKE (LIST<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; '(0 . "LAYER")<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; '(100 . "AcDbSymbolTableRecord")<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; '(100 . "AcDbLayerTableRecord")<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; '(6 . "continuous") ;线型<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (CONS 62 LAYER_COLOR) ;颜色<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; '(70 . 0) ;图层状态<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (CONS 2 LAYER_NAME) ;图层名<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; )<br>&nbsp;&nbsp; &nbsp;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<br>&nbsp;&nbsp;&nbsp; )&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; ;END IF<br>&nbsp;&nbsp;&nbsp; (SETQ I (1+ I))<br>&nbsp; )&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; ;END VLAX-FOR<br><br>&nbsp; ;;建立轴线层<br>&nbsp; (SETQ CHK_LAYER (TBLSEARCH "LAYER" "轴线"))<br>&nbsp; (IF (= CHK_LAYER NIL)<br>&nbsp;&nbsp;&nbsp; (PROGN<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (IF (NOT (TBLSEARCH "LTYPE" "CENTER"))<br>&nbsp;&nbsp; &nbsp;(ENTMAKE<br>&nbsp;&nbsp; &nbsp;&nbsp; '(<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (0 . "LTYPE")<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (100 . "AcDbSymbolTableRecord")<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (100 . "AcDbLinetypeTableRecord")<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (2 . "CENTER")<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (70 . 0)<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (3 . "Center ____ _ ____ _ ____ _ ____ _ ____ _ ____")<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (72 . 65)<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (73 . 4)<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (40 . 2.0)<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (49 . 1.25)<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (74 . 0)<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (49 . -0.25)<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (74 . 0)<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (49 . 0.25)<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (74 . 0)<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (49 . -0.25)<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (74 . 0)<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; )<br>&nbsp;&nbsp; &nbsp;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (EntMake (LIST<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; '(0 . "LAYER")<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; '(100 . "AcDbSymbolTableRecord")<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; '(100 . "AcDbLayerTableRecord")<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; '(6 . "CENTER") ;线型<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; '(62 . 1) ;颜色<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; '(70 . 0) ;图层状态<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; (CONS 2 "轴线") ;图层名<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<br>&nbsp;&nbsp;&nbsp; )<br>&nbsp; )<br>&nbsp; ;;END 轴线<br><br>&nbsp; ;;建立虚线层<br>&nbsp; (SETQ CHK_LAYER (TBLSEARCH "LAYER" "虚线"))<br>&nbsp; (IF (= CHK_LAYER NIL)<br>&nbsp;&nbsp;&nbsp; (PROGN<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (IF (NOT (TBLSEARCH "LTYPE" "HIDDEN"))<br>&nbsp;&nbsp; &nbsp;(ENTMAKE<br>&nbsp;&nbsp; &nbsp;&nbsp; '(<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (0 . "LTYPE")<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (100 . "AcDbSymbolTableRecord")<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (100 . "AcDbLinetypeTableRecord")<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (2 . "HIDDEN")<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (70 . 0)<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (3 . "Hidden __ __ __ __ __ __ __ __ __ __ __ __ __ _")<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (72 . 65)<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (73 . 2)<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (40 . 0.375)<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (49 . 0.25)<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (74 . 0)<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (49 . -0.125)<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (74 . 0)<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; )<br>&nbsp;&nbsp; &nbsp;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (ENTMAKE (LIST<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; '(0 . "LAYER")<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; '(100 . "AcDbSymbolTableRecord")<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; '(100 . "AcDbLayerTableRecord")<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; '(6 . "HIDDEN") ;线型<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; '(62 . 8) ;颜色<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; '(70 . 0) ;图层状态<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; (CONS 2 "虚线") ;图层名<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<br>&nbsp;&nbsp;&nbsp; )<br>&nbsp; )<br>&nbsp; ;;END 虚线<br><br>&nbsp; (PROMPT<br>&nbsp;&nbsp;&nbsp; "\n图层初始化完毕! &nbsp;&nbsp; &nbsp;BY HB.LEE . 2006-11-03."<br>&nbsp; ) ;_ 结束PROMPT<br>&nbsp; (PRINC)<br>)&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; ;END DEFUN

tcsl9621 发表于 2006-11-7 11:35:00

<P>你这就是脚本,我用LISP内部命令。</P>
<P>;;;============<BR>;;;= 设置图层 =<BR>;;;============</P>
<P>.(defun addtranslayer (/&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; styleobj1&nbsp;&nbsp; layerobj1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; layerobj2&nbsp;&nbsp;&nbsp;&nbsp; layerobj3&nbsp;&nbsp; layerobj4<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; layerobj5&nbsp;&nbsp;&nbsp;&nbsp; layerobj6&nbsp;&nbsp; layerobj7<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; layerobj8&nbsp;&nbsp;&nbsp;&nbsp; layerobj9&nbsp;&nbsp; layerobj10<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<BR>&nbsp; (vl-catch-all-apply<BR>&nbsp;&nbsp;&nbsp; 'vla-load<BR>&nbsp;&nbsp;&nbsp; (list p2c::linetypes<BR>&nbsp;&nbsp; "center"<BR>&nbsp;&nbsp; "acadiso.lin"<BR>&nbsp;&nbsp;&nbsp; )<BR>&nbsp; )<BR>&nbsp; (vl-catch-all-apply<BR>&nbsp;&nbsp;&nbsp; 'vla-load<BR>&nbsp;&nbsp;&nbsp; (list p2c::linetypes<BR>&nbsp;&nbsp; "DASHED"<BR>&nbsp;&nbsp; "acadiso.lin"<BR>&nbsp;&nbsp;&nbsp; )<BR>&nbsp; )<BR>&nbsp; (setq styleobj1 (vla-add p2c::textstyles "GB"))<BR>&nbsp; (vla-put-fontfile styleobj1 "gbenor.shx")<BR>&nbsp; (vla-put-bigfontfile styleobj1 "gbcbig.shx")<BR>&nbsp; (setq&nbsp;layerobj1&nbsp; (vla-add p2c::layersobj "KERFLEFT")<BR>&nbsp;layerobj2&nbsp; (vla-add p2c::layersobj "KERFRIGHT")<BR>&nbsp;layerobj3&nbsp; (vla-add p2c::layersobj "KERFOFF")<BR>&nbsp;layerobj4&nbsp; (vla-add p2c::layersobj "MARKING")<BR>&nbsp;layerobj5&nbsp; (vla-add p2c::layersobj "PLATE")<BR>&nbsp;layerobj6&nbsp; (vla-add p2c::layersobj "ZSQ")<BR>&nbsp;layerobj7&nbsp; (vla-add p2c::layersobj "CENTER")<BR>&nbsp;layerobj8&nbsp; (vla-add p2c::layersobj "DASHED")<BR>;;;<BR>&nbsp;layerobj9&nbsp; (vla-add p2c::layersobj "INSIDE")<BR>&nbsp;layerobj10 (vla-add p2c::layersobj "OUTSIDE")<BR>&nbsp; )<BR>;;;KERFLEFT<BR>&nbsp; (vla-put-color layerobj1 acred)<BR>&nbsp; (vla-put-lineweight layerobj1 aclnwt025)<BR>&nbsp; (vla-put-linetype layerobj1 "continuous")<BR>;;;KERFRIGHT<BR>&nbsp; (vla-put-color layerobj2 acred)<BR>&nbsp; (vla-put-lineweight layerobj2 aclnwt025)<BR>&nbsp; (vla-put-linetype layerobj2 "continuous")<BR>;;;KERFNO<BR>&nbsp; (vla-put-color layerobj3 acred)<BR>&nbsp; (vla-put-lineweight layerobj2 aclnwt025)<BR>&nbsp; (vla-put-linetype layerobj3 "continuous")<BR>;;;MARKING<BR>&nbsp; (vla-put-color layerobj4 accyan)<BR>&nbsp; (vla-put-lineweight layerobj4 aclnwt025)<BR>&nbsp; (vla-put-linetype layerobj4 "continuous")<BR>;;;PLATE<BR>&nbsp; (vla-put-color layerobj5 acblue)<BR>&nbsp; (vla-put-lineweight layerobj2 aclnwt030)<BR>&nbsp; (vla-put-linetype layerobj5 "continuous")<BR>;;;ZSQ<BR>&nbsp; (vla-put-color layerobj6 acwhite)<BR>&nbsp; (vla-put-linetype layerobj6 "continuous")<BR>;;;CENTER<BR>&nbsp; (vla-put-color layerobj7 acred)<BR>&nbsp; (vla-put-linetype layerobj7 "CENTER")<BR>;;;DASHED<BR>&nbsp; (vla-put-color layerobj8 acgreen)<BR>&nbsp; (vla-put-linetype layerobj8 "DASHED")<BR>;;;INSIDE<BR>&nbsp; (vla-put-color layerobj9 acgreen)<BR>&nbsp; (vla-put-lineweight layerobj9 aclnwt025)<BR>&nbsp; (vla-put-linetype layerobj9 "continuous")<BR>;;;OUTSIDE<BR>&nbsp; (vla-put-color layerobj10 acred)<BR>&nbsp; (vla-put-lineweight layerobj10 aclnwt025)<BR>&nbsp; (vla-put-linetype layerobj10 "continuous")<BR>;;;END<BR>&nbsp; (princ)<BR>)</P>

野狼谷/〈M〉 发表于 2012-9-2 18:06:39

忙了一下午,才看到这还有现成的

林霄云 发表于 2013-12-28 17:21:07

本帖最后由 林霄云 于 2013-12-28 17:22 编辑

批量生成图层用mapcar和lambda命令,语句可以简练很多。示例setup_layers(defun setup_Layers()
(mapcar '(lambda(layname laycolor linetype linewidth)

(command "layer"   "m"             layname
   "c"      laycolor          layname
   "l"         linetype         layname
   "lw"          linewidth      layname
   ""
    )
   (princ layname)
);lambda
'("G-AXIS(主轴线)""G-AXIS_TEXT(轴线号)""G-LABEL(引线)""G-SLAB-HATCH(板填充)""G-STAIR(楼梯)"
)
'("9""255""3""11""2"
)
'("_AXIS100""CONTINUOUS""CONTINUOUS""CONTINUOUS""CONTINUOUS"
)
'("0.13""0.3""0.13""0.13""0.13"
)
);mapcar
(setvar "clayer" "0"); 当年图层置为“0”
);defun

混沌初开 发表于 2013-12-30 17:06:14

楼主是做冲压模具设计?
页: [1] 2
查看完整版本: 自动建图层lsp