你好
作为练习,我正在lisp中尝试另一种方法。
我用一个列表来检查/创建图层,它让我想到我可以做更多。
- (setq layLst '(
- (("CNC_DRILL-.10-PLEX" 30))
- (("CNC_DRILL-.30-CTRSINK" 241))
- (("CNC_DRILL-.125-PILOT" 9))
- (("CNC_DRILL-.1875-THRU" 4))
- (("CNC_DRILL-.250-PEG" 1))
- (("CNC_DRILL-.250-THRU" 6))
- (("CNC_DRILL-.3125-THRU" 3))
- (("CNC_DRILL-.375-THRU" 6))
- (("CNC_DRILL-.500-THRU" 2))
- (("CNC_PLY-DOWEL" 211))
- (("CNC_PLY-T-NUT-RECESS" 2))
- (("CNC_PLY-GROMMET" 40))
- (("CNC_PLY-SLOT" 1))
- ) ; end comLst
- ) ;_ end of setq
- (foreach itm layLst
- (if (not (tblsearch "LAYER" (caar itm)))
- (progn
- (setq nLay (vla-Add (vla-get-Layers
- (vla-get-ActiveDocument
- (vlax-get-acad-object)
- ) ;_ end of vla-get-ActiveDocument
- ) ;_ end of vla-get-Layers
- (caar itm)
- ) ;_ end of vla-Add
- ) ;_ end of setq
- (vla-put-Color nLay (cadar itm))
- ) ; end progn
- ) ; end if
- (command "_.layer"
- "_on" (caar itm)
- "_thaw" (caar itm)
- "_unlock" (caar itm)
- ""
- )
- ) ;_ end of foreach
此例行程序的其余部分(使用cond)检查圆半径,并将圆放置在其相应的层上(使用命令)。如果需要的话,我可以发布整个程序。
我想知道是否可以将半径添加到layLst,并使用foreach语句对照它检查选择集,从而消除多个条件语句。
- (setq layLst '(
- (("CNC_DRILL-.10-PLEX" 30) 0.10)
- (("CNC_DRILL-.30-CTRSINK" 241) 0.30)
- (("CNC_DRILL-.125-PILOT" 9) 0.125)
- (("CNC_DRILL-.1875-THRU" 4) 0.1875)
- (("CNC_DRILL-.250-PEG" 1) 0.250)
- (("CNC_DRILL-.250-THRU" 6))
- (("CNC_DRILL-.3125-THRU" 3) 0.3125)
- (("CNC_DRILL-.375-THRU" 6) 0.375)
- (("CNC_DRILL-.500-THRU" 2) 0.5)
- (("CNC_PLY-DOWEL" 211))
- (("CNC_PLY-T-NUT-RECESS" 2))
- (("CNC_PLY-GROMMET" 40))
- (("CNC_PLY-SLOT" 1))
- ) ; end comLst
- ) ;_ end of setq
这似乎应该是可能的。
任何帮助都将不胜感激。 |