skotseno Posted July 9, 2012 Share Posted July 9, 2012 I am new to this but I need a lisp that would create the following layers with every (even pre existing) files that I open. Layer: 1 in cyan, 2 in white, 2L in white, 3 in red, 4 in yellow, 5 in white, 6 in blue, SK1 in cyan, SK2 in white, SK3 in red, SK4 in yellow, and SK6 in blue. I have looked at existing lisps and macros but I am new and am having trouble making sense of them. Quote Link to comment Share on other sites More sharing options...
MSasu Posted July 9, 2012 Share Posted July 9, 2012 I think this will do the trick; please try to fill by yourself the remaining cases: (foreach layerItem '([color=blue][color=red]("1" 4) [color=orange]("2" 7)[/color][/color] ("2L" 7)[/color]) (entmake (list '(0 . "LAYER") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbLayerTableRecord") (cons 2 (car layerItem)) '(70 . 0) (cons 62 (cadr layerItem)) '(6 . "Continuous"))) ) Quote Link to comment Share on other sites More sharing options...
SLW210 Posted July 9, 2012 Share Posted July 9, 2012 I moved this thread to the AutoLISP, Visual LISP & DCL forum for you. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 9, 2012 Share Posted July 9, 2012 I am new to this but I need a lisp that would create the following layers with every (even pre existing) files that I open. Layer: 1 in cyan, 2 in white, 2L in white, 3 in red, 4 in yellow, 5 in white, 6 in blue, SK1 in cyan, SK2 in white, SK3 in red, SK4 in yellow, and SK6 in blue. I have looked at existing lisps and macros but I am new and am having trouble making sense of them. Why not simply make these layers part of your template? I think this will do the trick; please try to fill by yourself the remaining cases: (foreach layerItem '([color=blue][color=red]("1" 4) [color=orange]("2" 7)[/color][/color] ("2L" 7)[/color]) (entmake (list '(0 . "LAYER") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbLayerTableRecord") (cons 2 (car layerItem)) '(70 . 0) (cons 62 (cadr layerItem)) '(6 . "Continuous"))) ) Building on Mircea's post, here's a Visual LISP adaptation: ((lambda (oLayers / layerName) (foreach layerItem '(("1" 4) ("2" 7) ("2L" 7)) (vla-put-color (apply (if (tblsearch "layer" (setq layerName (car layerItem))) 'vla-item 'vla-add ) (list oLayers layerName) ) (cadr layerItem) ) ) ) (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)) ) ) Quote Link to comment Share on other sites More sharing options...
MSasu Posted July 9, 2012 Share Posted July 9, 2012 Why not simply make these layers part of your template? That was my first thought also, but next notified that OP was looking to have that layer structure created on existing drawings too. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted July 10, 2012 Share Posted July 10, 2012 Old fashioned script will do also just open in notepad add layers change etc -la n layer1 C layer1 1 n layer2 C layer2 2 n layer3 C layer3 3 Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 10, 2012 Share Posted July 10, 2012 See here and here. Quote Link to comment Share on other sites More sharing options...
skotseno Posted July 10, 2012 Author Share Posted July 10, 2012 Thanks Lee Mac! I tried posting this code into acaddoc but nothing happens. please advise. (defun _layer3 ( name color linetype lineweight plot ) (if (null (tblsearch "LAYER" name)) (entmake (list '(0 . "LAYER") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbLayerTableRecord") '(70 . 0) (cons 1 name) (cons 6 linetype) (cons 4 colour) (cons 290 plot) (cons 15 lineweight) ) ) ) ) (_layer3 "2" 7 "Continuous" 15 1) (_layer3 "2L" 7 "Continuous" 15 1) (_layer3 "3" 1 "Hidden" 15 1) (_layer3 "4" 2 "Center" 15 1) (_layer3 "SK1" 4 "Continuous" 15 1) (_layer3 "SK2" 7 "Continuous" 15 1) (_layer3 "SK3" 1 "Hidden" 15 1) (_layer3 "SK4" 2 "Center" 15 1) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 10, 2012 Share Posted July 10, 2012 Firstly, please use Code Tags when posting code. You haven't copied the code correctly, the DXF group codes are wrong... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.