LAYFRZ except for changing layer color??

LAYFRZ except for changing layer color??

Anonymous
Not applicable
503 Views
2 Replies
Message 1 of 3

LAYFRZ except for changing layer color??

Anonymous
Not applicable

Right now my workflow for changing the color of a layer nested within an xref is to use xlist to find the layer, search the layer in the layer menu, and then change the color from there. Is there a faster way to change a nested layer's color? 

 

I'm thinking of a command that allows you to select an object (including nested within xrefs) and brings up the color dialogue for that layer, essentially functioning the same way as LAYFRZ.  If not, would this be possible to create with a LISP routine? I've never created a LISP routine before, but it may be worth the time investment for me to be able to accomplish this. 

0 Likes
Accepted solutions (1)
504 Views
2 Replies
Replies (2)
Message 2 of 3

ВeekeeCZ
Consultant
Consultant
Accepted solution

Yes, that's exactly task for a LISP routine. And yes, it worth some time spending to learn at least some basics.

 

(defun c:XLayerColor (/ e l c)
  
  (if (and (setq e (car (nentsel "\nSelect nested entity: ")))
	   (setq l (cdr (assoc 8 (entget e))))
	   (princ (strcat "\nSelected LAYER: " l))
	   (not (terpri))
	   (setq c (cdr (assoc 62 (tblsearch "LAYER" l))))
	   (setq c (acad_colordlg c nil))
	   )
    (command "_.-layer" "_color" c l ""))
  (princ)
  )

HERE is a tutorial how to use LISP.

Message 3 of 3

Kent1Cooper
Consultant
Consultant

@ВeekeeCZ wrote:

....

....
(if (and (setq e (car (nentsel "\nSelect nested entity: "))) (setq l (cdr (assoc 8 (entget e)))) (princ (strcat "\nSelected LAYER: " l)) ....

....


 

One thing to be careful of:  The (nentsel) function "sees" the deepest-nested level  of the selected object or nested object.  So if you pick on a Block  in an Xref, or a Block nested in another Block nested in another Block in an Xref, and the piece of the down-at-the-lowest-level Block on which you pick was originally drawn on Layer 0, what this will do is to change the color of Layer 0, not  of the "apparent" Layer on which that Block was inserted.  And since Layer 0 is a universalized one [i.e. there's never a nested-in-Xref Layer named YourXrefName|0], it will change the color of Layer 0 in the current drawing.

 

If that could be a concern, it is possible to "step up" in that situation until it encounters a Layer on which something is inserted that isn't  0, and change that one's color instead -- it's in the commands whose names end with N [for Nested] in LayerQuellPick.lsp, >here<.  You could alter those commands to change the color rather than to turn Off or Freeze.

Kent Cooper, AIA