Jump to content

XREF Layers


smorales02

Recommended Posts

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 8). 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

Link to comment
Share on other sites

  • Replies 20
  • Created
  • Last Reply

Top Posters In This Topic

  • smorales02

    11

  • ReMark

    7

  • ASMI

    3

Top Posters In This Topic

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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;\;

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...