smorales02 Posted September 3, 2008 Share Posted September 3, 2008 Did a quick search but couldn't really find what I am after, unless I just missed it. i am trying to find the fastest way posibble of changing all the layers of an xref to a different color (example: color . Now I know you can open Layer Manager than select the layers and change it that way, which is fine, but im trying to minimize the steps involved.. Maybe just be prompted to select the xref than input a color and the layers would change. If anyone could help that would be great. Thanks in advance Quote Link to comment Share on other sites More sharing options...
ReMark Posted September 3, 2008 Share Posted September 3, 2008 Seek and ye shall find? Try this link, maybe there's something that will work for you. http://www.cadforum.cz/cadforum_en/qaID.asp?tip=5754 Quote Link to comment Share on other sites More sharing options...
smorales02 Posted September 3, 2008 Author Share Posted September 3, 2008 the second option would be what I am after, now how would I create a lisp/macro to be able to have the user select the xref that needs to change? Quote Link to comment Share on other sites More sharing options...
ReMark Posted September 3, 2008 Share Posted September 3, 2008 I would think you could just use the -layer command as suggested. Try it out via your command line first and jot down the steps you take as you go along. These steps will form the basis of your new macro. Quote Link to comment Share on other sites More sharing options...
smorales02 Posted September 3, 2008 Author Share Posted September 3, 2008 Ok Ill give it a try...Ill let you know how it goes. Quote Link to comment Share on other sites More sharing options...
smorales02 Posted September 3, 2008 Author Share Posted September 3, 2008 The way described in your link works perfect, but only works if you want to change all the xrefs to the color. Here is the command prompt for it: Command: -LAYER Current layer: "TEXT" Enter an option [?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]: C New color [Truecolor/COlorbook] : 8 [color=red]Enter name list of layer(s) for color 8 <TEXT>: *|*[/color] Enter an option [?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]: The line in red is what I need to be able to change. I need to be able to just selct the xref and have it apply to only that one. I dont know any way of doing this without LISP or VBA and unfortunetly i am not very good at either one. Any suggestions? Quote Link to comment Share on other sites More sharing options...
ReMark Posted September 3, 2008 Share Posted September 3, 2008 It should go something like this: -layer C (for color) 9 (for new color or whatever number equates to the color you want) Xref* (for name of layers you wish to change the color of; is a wildcard) These are the basic components needed. Just add the appropriate syntax that AutoCAD expects to see in a macro. Example: ^C^C-layer (this gets the command started). You can automate the command by inserting the desired responses (see above) or you can leave it to the user to decide. Quote Link to comment Share on other sites More sharing options...
smorales02 Posted September 3, 2008 Author Share Posted September 3, 2008 how can I make the XREF part a user defined selection without having to type in the name of the XREF? Quote Link to comment Share on other sites More sharing options...
ReMark Posted September 3, 2008 Share Posted September 3, 2008 The backslash is used in a macro where user input is desired. If I wanted to ask the user to set a layer using a macro I would write it thusly: ^C^C-layer;S;\; Quote Link to comment Share on other sites More sharing options...
smorales02 Posted September 3, 2008 Author Share Posted September 3, 2008 Doesnt seem like I can do what I want to do with the -layer command. Here is my macro ^C^C-LAYER;C;8;\; Here is what happens when I run it. Command: -LAYER Current layer: "TEXT" Enter an option [?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]: C New color [Truecolor/COlorbook] : 8 Enter name list of layer(s) for color 8 <TEXT>: Just stops there and waits for me to type in a layer name Quote Link to comment Share on other sites More sharing options...
ReMark Posted September 3, 2008 Share Posted September 3, 2008 And your problem is you do not want to type in a layer name? If that's the case then supply the layer name in your macro. Quote Link to comment Share on other sites More sharing options...
smorales02 Posted September 4, 2008 Author Share Posted September 4, 2008 Its not that I dont want to type in a layer name, its that i want to change all the layers in a specified XREF but the XREF's name changes from project to project. So I would like to be able to just select the xref that I want changed and have it change all the layers in that XREF, I just dont know how to do that with LISP. Quote Link to comment Share on other sites More sharing options...
ReMark Posted September 4, 2008 Share Posted September 4, 2008 If the name of the XREF drawing changes from drawing session to drawing session then you would have to allow for the user to input the name via the keyboard or construct a routine that would automatically find and insert the name. Is there any possibility that a drawing would have more than one XREF? Quote Link to comment Share on other sites More sharing options...
ReMark Posted September 4, 2008 Share Posted September 4, 2008 Suggestion: Join the CAD Tips forum at CADalyst Magazine. It's free. Do a search on "change layer color". One of the submitted routines does something very close to what you are trying to do. I think it's called "Xref to Color 9". Good luck. Quote Link to comment Share on other sites More sharing options...
smorales02 Posted September 4, 2008 Author Share Posted September 4, 2008 Found one that looks like it will work, need to test it out though. I will test and post back the results. Quote Link to comment Share on other sites More sharing options...
ASMI Posted September 4, 2008 Share Posted September 4, 2008 Short example how to select all XRef layers and change color: (defun c:xrcol(/ lLst nCol) (vl-load-com) (vlax-for l(vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object))) (if(wcmatch(vla-get-Name l) "*|*") (setq lLst(cons l lLst)) ); end if ); end vlax-for (if(and lLst (setq nCol(acad_colordlg 8 nil)) ); end and (foreach l lLst (vla-put-Color l nCol) ); end foreach ); end if (princ) ); end of c:xrcol Quote Link to comment Share on other sites More sharing options...
smorales02 Posted September 4, 2008 Author Share Posted September 4, 2008 ASMI Your routine changes all the xrefs to a user defined color, I would like to be able to choose the XREF (by clicking on it) that I want to change. Thank you for the reply Quote Link to comment Share on other sites More sharing options...
ASMI Posted September 4, 2008 Share Posted September 4, 2008 Something like this (change nested entities color not layers color). I think it need to add original colors restore ability and locked/frozen layers release (maybe). Isn't it? (defun c:xrcol(/ xSet actDoc nCol blCol blLst) (vl-load-com) (princ "\n<<< Select XRefs to change color >>> ") (if (setq xSet(ssget '((0 . "INSERT")))) (if(setq nCol(acad_colordlg 8 nil)) (progn (setq blCol(vla-get-Blocks (setq actDoc(vla-get-ActiveDocument (vlax-get-acad-object)))) blLst(mapcar 'vla-get-Name (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr(ssnamex xSet))))) ); end setq (while blLst (setq cBl(vla-Item blCol(car blLst)) blLst(cdr blLst) ); end setq (vlax-for i cBl (vl-catch-all-apply 'vla-put-Color(list i nCol)) (if(= "AcDbBlockReference"(vla-get-ObjectName i)) (setq blLst(append blLst (list(vla-get-Name i)))) ); end if ); end vlax-for ); end while (vla-Regen actDoc acAllViewports) ); end progn ); end if ); end if (vl-load-com) ); end of c:xrcol Quote Link to comment Share on other sites More sharing options...
smorales02 Posted September 4, 2008 Author Share Posted September 4, 2008 That is exactly what I am looking for...I wish I could understand what the code is doing line by line, but im not that advanced in programing.. I have one question though... Is it just overriding the layer visually? In other words after i ran the porgram I went to the layer manager to see what it did and the layer colors are all the original color, but visually it changed to the color I chose. This is not a big deal, I was just wondering for my own curiosity.. I do think that adding a restore option would be a great idea. Maybe after selecting the XREF your prompted at the command line to Change or Restore. Thank you very much Quote Link to comment Share on other sites More sharing options...
ASMI Posted September 4, 2008 Share Posted September 4, 2008 I wish I could understand what the code is doing line by line, but im not that advanced in programing.. It not so hard. You can to run program in debug mode inside Visual LISP Editor. Wach to variables values and read functions help. I have one question though...Is it just overriding the layer visually? In other words after i ran the porgram I went to the layer manager to see what it did and the layer colors are all the original color, but visually it changed to the color I chose. This is not a big deal, I was just wondering for my own curiosity.. This program put a certain color to all nested entities. The other way - set all nesed entities color ByLayer and change XRef layers color. I do think that adding a restore option would be a great idea. Maybe after selecting the XREF your prompted at the command line to Change or Restore. Ok. I make it tomorrow or at next week (not in weekend). 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.