awill81 Posted June 24, 2009 Share Posted June 24, 2009 I'm not too fluent with lisp so I was hoping someone could help me with creating a layer update lisp. We have old drawings that have old layers and we use them on newer projects. I want to create a lisp that can rename old layers that have the same lineweight, color, and linetype to the newer later name. And I think I'd need some if statements for if those newer layers already exist or if any of the older layers don't exist, it creates the new layer. Any help would be appreciated. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 24, 2009 Share Posted June 24, 2009 See here Lee Quote Link to comment Share on other sites More sharing options...
N_461 Posted July 5, 2010 Share Posted July 5, 2010 Hi this is exactly what I've been looking for. I am new to lisp's and we are trying to get a template going. I think that lsip routines are the way to go. I sort of understand your link, but could you explain it a little? I'd be looking for just the new layer part, and i take it one would fill in the magenta type? Im a little confused on which part creates the layer and which changes the old layer to the new. thanks! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 5, 2010 Share Posted July 5, 2010 My code will just create new layers using the subfunction 'MkLay' - which takes a layer name, colour, Linetype, Lineweight, and whether the layer is plottable - it will not amend existing layers. I use mapcar in the main function to iterate the subfunction through a list of layer names/colours/lineweights etc. This is an old code and could most probably be written much better however. Quote Link to comment Share on other sites More sharing options...
N_461 Posted July 14, 2010 Share Posted July 14, 2010 This works great. I'm wondering about the spacing between each layer name and the respective colour code, linetype, etc.-- is there a specific number or is it good as long as they are under each other in relative columns?? I'm just using notepad to do my editing.... Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 14, 2010 Share Posted July 14, 2010 LISP doesn't care for whitespace, so any spacing will do - the only proviso is the order in which they are in the lists. Quote Link to comment Share on other sites More sharing options...
N_461 Posted September 1, 2010 Share Posted September 1, 2010 Hey Lee, I've populated the lisp to create a specific layerset. My questions: HOW do I set ALL layer properties? I have colour, LT, LW, Plotable, but can i set the layer to be frozen/thawed, on/off, locked? Can i input layer descriptions? ...thanks a tonne! Im actually learning....a bit... Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 1, 2010 Share Posted September 1, 2010 That's pretty old code, Perhaps try this instead: (defun MakeLayer ( name colour linetype lineweight willplot bitflag description ) ;; © Lee Mac 2010 (or (tblsearch "LAYER" name) (entmake (append (list (cons 0 "LAYER") (cons 100 "AcDbSymbolTableRecord") (cons 100 "AcDbLayerTableRecord") (cons 2 name) (cons 70 bitflag) (cons 290 (if willplot 1 0)) (cons 6 (if (and linetype (tblsearch "LTYPE" linetype)) linetype "CONTINUOUS" ) ) (cons 62 (if (and colour (< 0 (abs colour) 256)) colour 7)) (cons 370 (fix (* 100 (if (and lineweight (<= 0.0 lineweight 2.11)) lineweight 0.0) ) ) ) ) (if description (list (list -3 (list "AcAecLayerStandard" (cons 1000 "") (cons 1000 description)) ) ) ) ) ) ) ) (defun c:MakeLayers ( ) ;; © Lee Mac 2010 ( (lambda ( lst ) (mapcar 'cons (car lst) (apply 'mapcar (cons 'MakeLayer lst))) ) '( ( "CEN" "DIMS" "HAT" "HID" "LOGO" "OBJ" "PAPER" "PHAN" "TITLE" "TXT" ) ; Layer Name [ STR ] ( 6 -1 3 4 176 -2 5 6 176 7 ) ; Layer Colour (-ve for layer off) [ INT ] ("CENTER" nil nil "HIDDEN" nil nil "PHANTOM" "PHANTOM" nil nil ) ; Layer LineType [ STR ] ( 0.18 0.18 0.18 0.15 0.09 0.40 nil 0.18 nil nil ) ; Layer LineWeight [ REAL ] ( T T T T T T nil T T T ) ; Plot? (T or nil) [ BOOLE ] ( 0 1 5 0 0 3 6 0 1 0 ) ; Bit Flag (0 = None, 1=Frozen, 2=Frozen in Vp, 4=Locked) [ INT ] ( nil "Dimensions" nil "Hidden""For Logo" nil nil nil "For Title" nil ) ; Description (nil for none) [ STR ] ) ) ) Linetypes must already be loaded, all arguments in list must be of correct type and range. Success of layer creation will be displayed in resultant list. Lee Quote Link to comment Share on other sites More sharing options...
N_461 Posted September 1, 2010 Share Posted September 1, 2010 Thanks Lee! I'll try that out this week. Is it possible to incorporate a lisp that will rename existing layers to the new layer? Quote Link to comment Share on other sites More sharing options...
alanjt Posted September 1, 2010 Share Posted September 1, 2010 Wouldn't this be easier to deal with and edit? (defun c:Foo nil (mapcar '(lambda (x) (apply 'MakeLayer x)) '(("CEN" 6 "CENTER" 0.18 T 0 nil) ("DIMS" -1 nil 0.18 T 1 "Dimensions") ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 1, 2010 Share Posted September 1, 2010 Hahaha - very much so... guess I got lost in my original train of thought with this one, thanks Alan. Quote Link to comment Share on other sites More sharing options...
N_461 Posted September 1, 2010 Share Posted September 1, 2010 seems simpler, i'll try that too Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 1, 2010 Share Posted September 1, 2010 seems simpler, i'll try that too Both will function identically, however the layout of Alan's code is easier to manage as easier layer has its own entry in the list. Lee Quote Link to comment Share on other sites More sharing options...
alanjt Posted September 2, 2010 Share Posted September 2, 2010 Hahaha - very much so... guess I got lost in my original train of thought with this one, thanks Alan.We all put on code blinders, at times. Quote Link to comment Share on other sites More sharing options...
javid Posted September 2, 2010 Share Posted September 2, 2010 Dear Lee,It was so usefull for me too...Thanks for your help...B.Regards,Javid. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 2, 2010 Share Posted September 2, 2010 You're very welcome Javid Quote Link to comment Share on other sites More sharing options...
N_461 Posted September 7, 2010 Share Posted September 7, 2010 How do you execute the routine? I'd need it to load on command, as Lee's did. Im sure its a simple fix, but i tried a few things and kept getting errors... thanks! Wouldn't this be easier to deal with and edit? (defun c:Foo nil (mapcar '(lambda (x) (apply 'MakeLayer x)) '(("CEN" 6 "CENTER" 0.18 T 0 nil) ("DIMS" -1 nil 0.18 T 1 "Dimensions") ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
alanjt Posted September 7, 2010 Share Posted September 7, 2010 Type 'Foo'. Quote Link to comment Share on other sites More sharing options...
N_461 Posted September 7, 2010 Share Posted September 7, 2010 baaah........I'm'a foo.... Thanks man. Is it monday???? You guys should do webinars.... Quote Link to comment Share on other sites More sharing options...
N_461 Posted September 7, 2010 Share Posted September 7, 2010 sometimes i'll get an undefined for nil?? i add this to lee's correct? 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.