leos98 Posted April 1, 2009 Posted April 1, 2009 Hello, I looking for a routine that will change specific layer color to colors I want. For example, change all layers with color=10 to color=13, layer with color=50 to color=53 and so on. I need so that when we set xrefs in our company we can offset the architect’s layer colors. Thanks! Leos98 Quote
GE13579 Posted April 1, 2009 Posted April 1, 2009 QSELECT can be useful for this kind of thing, depending on the number of layers and drawings you need to change. The use PROPERTIES once the layer is selected. Quote
leos98 Posted April 1, 2009 Author Posted April 1, 2009 Thanks, But what I’m trying to do is create a routine to set up xrefs. So far I have one that takes the architec’s drawing and detaches all of the xrefs he has, sets all objects to BYLAYER, PURGES the drawing and other things. Now, I also want to include the color changing routine to it. Quote
GE13579 Posted April 1, 2009 Posted April 1, 2009 Ok sorry I can't be of more help, but all being well a Mod could move this into the AutoLISP/ VBA... section? Quote
Tiger Posted April 1, 2009 Posted April 1, 2009 There is a command that changes, merges and suchlikes with layers... unfortunatly I can't remember that, and have no access to autocad today (forgot to borrow a license - doh!) so can't check it out.... if nothing else, I'll check it up tomorrow. Quote
lpseifert Posted April 1, 2009 Posted April 1, 2009 Here's an oldie by Bill Kramer. It changes the color of all entities (if not Bylayer), not just layers... COLORF.LSP Quote
leos98 Posted April 1, 2009 Author Posted April 1, 2009 Thanks, I downloaded and it looks very complex. I do not even know how to incorporate it into my already created routine. Is there something simpler? Quote
Tiger Posted April 2, 2009 Posted April 2, 2009 The command I was thinking of is called LAYTRANS - if you have a template with the correct layers, LAYTRANS lets you translate layers in your drawing to those of your chosen template. You can save these translatations to be used again. Quote
Lee Mac Posted April 2, 2009 Posted April 2, 2009 This will just change layer colour - will only affect ents set to "bylayer" (defun c:laycol (/ colLst lay col) (vl-load-com) (setq colLst '((10 . 13) ;; <<---<< Edit this as necessary (50 . 53) )) (vlax-for l (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) (setq lay (cons l lay))) (foreach layer lay (if (setq col (assoc (vla-get-color layer) colLst)) (vla-put-color layer (cdr col)))) (princ)) Quote
leos98 Posted April 2, 2009 Author Posted April 2, 2009 Lee Mac Thanks, it works great, is there a way that instead of doing (10 . 13) I can do (red . 13) I tried it but it didn't work. Quote
leos98 Posted April 2, 2009 Author Posted April 2, 2009 I got it, Instead of red I just did (1 . 13), for a minute i was confused and thought 10 was red. But now, what we want to do is change all of the colors in a range. for example, all colors from 10 thru 19 be change to 15, all colors from 20 thru 29 be change to 25. Any thoughts Thanks! Quote
leos98 Posted April 2, 2009 Author Posted April 2, 2009 Hey, Can I copy the LISP into the macro of a button? Quote
Lee Mac Posted April 2, 2009 Posted April 2, 2009 Hey,Can I copy the LISP into the macro of a button? For the macro, just make a call to the LISP's syntax from the macro button. Quote
Lee Mac Posted April 2, 2009 Posted April 2, 2009 Try this for ranges: (defun c:laycol (/ colLst lay col) (vl-load-com) (setq colLst '( ((10 19) 15) ;; <<---<< Edit this as necessary ((20 29) 25) )) (vlax-for l (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) (setq lay (cons l lay))) (foreach layer lay (foreach col colLst (if (<= (caar col) (vla-get-color layer) (cadar col)) (vla-put-color layer (cadr col))))) (princ)) Ammend as necessary Quote
leos98 Posted April 2, 2009 Author Posted April 2, 2009 Thanks, I did that andit works, any ideas about the range of colors. I'm sorry for bothering so much but this is my first time working with lisp and I really want to get this working. Thanks again, Leos98 Quote
leos98 Posted April 2, 2009 Author Posted April 2, 2009 Wow men I thank you a lot, a little late on my reply Quote
Lee Mac Posted April 2, 2009 Posted April 2, 2009 Wow men I thank you a lot, a little late on my reply Haha - range of colours already sorted dude Quote
leos98 Posted April 3, 2009 Author Posted April 3, 2009 Lee Mac First of all I would like to thank you for all of your help. I just tried the new routine but I keep getting the following error: ; error: bad argument type: consp 1 I have tried to understand it but due to my lack of knowledge in AUTOLISP have not being able to figure out. Can you please help me with this and also try to explain what is happening so I can start learning? Thanks! Leos98 Quote
Lee Mac Posted April 3, 2009 Posted April 3, 2009 Lee MacFirst of all I would like to thank you for all of your help. I just tried the new routine but I keep getting the following error: ; error: bad argument type: consp 1 I have tried to understand it but due to my lack of knowledge in AUTOLISP have not being able to figure out. Can you please help me with this and also try to explain what is happening so I can start learning? Thanks! Leos98 Hmm... I can't seem to reproduce the error that you are receiving - have you modified the posted code? If so, could you post the modified code? Cheers Quote
leos98 Posted April 3, 2009 Author Posted April 3, 2009 What I have done is the following: (defun c:laycol1 (/ colLst lay col) (vl-load-com) (setq colLst '( ((10 19) 15) ;; ((20 29) 25) ((30 39) 35) ((40 49) 45) ((50 59) 55) ((60 69) 65) ((70 79) 75) ((80 89) 85) ((90 99) 95) ((100 109) 105) ((110 119) 115) ((120 129) 125) ((130 139) 135) ((140 149) 145) ((150 159) 155) ((160 169) 165) ((170 179) 175) ((180 189) 185) ((190 199) 195) ((200 209) 205) ((210 219) 215) ((220 229) 225) ((230 239) 235) ((240 249) 245) (1 . 15) (2 . 55) (3 . 95) (4 . 135) (5 . 175) (6 . 215) (7 . 9) )) (vlax-for l (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) (setq lay (cons l lay))) (foreach layer lay (foreach col colLst (if ( (vla-put-color layer (cadr col))))) (princ)) Thanks! Quote
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.