A better method for changing xref layers in current drawing?

A better method for changing xref layers in current drawing?

claimed4all
Advocate Advocate
4,979 Views
9 Replies
Message 1 of 10

A better method for changing xref layers in current drawing?

claimed4all
Advocate
Advocate

We are currently using Civil3D 2016.

 

Some of my Parent Drawings may have 5-6 xrefs with about 500-1,000 layers per drawing.  So I can easily have a drawing with 4,000 layers.

 

Sometimes I need to make an xrefed layer looking different in my parent drawing.  My Current method in my parent drawing is:

  • '-xlist' command and select the object I want to change
  • Hit F2 to expand my command line and then copy and paste the entire layer name, including the xref prefix
  • Open my layer manager and paste the layer name in the search bar
  • Change the layer properties
  • Then '-xlist' the next layer I want to change

 

Sometimes I need to change 20-30 very random items and was wondering if there was a faster way, be it a built in command, lisp, add-in.

 

What I would love would be a command to run where I pick a layer and I get a pop up dialog of the layer options (color/LW/LT...)

0 Likes
Accepted solutions (1)
4,980 Views
9 Replies
Replies (9)
Message 2 of 10

ВeekeeCZ
Consultant
Consultant

You can use this simple lisp (or rewrite it to macro) to make a current layer by picking nested entity. Command is NC.

 

(defun c:NC () (setvar 'CLAYER (cdr (assoc 8 (entget (car (nentsel "\nSelect nested entity: ")))))) (princ))

0 Likes
Message 3 of 10

claimed4all
Advocate
Advocate

I gave that a shot and it does not appear to work.

 

This is how the command works out

Command: nc
Select nested entity:(this is where I picked an xref layer) ; error: AutoCAD variable setting rejected: CLAYER "xref-layer-name"

 

 

0 Likes
Message 4 of 10

Kent1Cooper
Consultant
Consultant

@ВeekeeCZ wrote:

.... 

(defun c:NC () (setvar 'CLAYER (cdr (assoc 8 (entget (car (nentsel "\nSelect nested entity: ")))))) (princ))


In my older version [2004] where I am at the moment, that doesn't work -- it won't let you make an Xref-dependent Layer current.  [It works for nested entities in ordinary Blocks, but not in Xrefs.]  Does it actually work in newer versions?

Kent Cooper, AIA
0 Likes
Message 5 of 10

ВeekeeCZ
Consultant
Consultant
Accepted solution

Sorry guys, my bad.

 

But here is a different idea - tmp layer filter. Pick how many entities you want, then go to the layer manager.

 

(defun c:tmplf ( / en lays) ; tmp layer filter

  (setq lays "")
  (while (setq en (nentsel "\nSelect nested layer: "))
    (setq lays (strcat (princ (cdr (assoc 8 (entget (car en))))) "," lays)))
  (if (/= lays "")
    (command "_.-LAYER" "_FILTER" "_Delete" "tmp" ""
	     "_.-LAYER" "_FILTER" "_New" "_Group" "" lays "tmp" ""))
  (princ)
)

 

@Kent1Cooper You're right. I was suspicious, but I tested it on block accidentally, I thought it was a xref.

Message 6 of 10

Kent1Cooper
Consultant
Consultant

Another approach you could consider:

 

Get the nested Layer name with a modification of BeekeeCZ's first suggestion:

(defun c:GNL ()

  (setq layname (cdr (assoc 8 (entget (car (nentsel "\nSelect nested entity: "))))))

  (princ)

)

 

Then, though for some reason a Command-line manual Layer command won't accept the typical use-what's-in-a-variable thing with the preceding exclamation point:

 

!layname

 

as a Layer name in a property-assignment option, it can be done with an AutoLisp Layer command using that variable:

(command "_.layer" "_color" 123 layname "")

 

That could be automated, for example into a command to change the color of such a Layer [lightly tested]:

(defun C:CNLC (/ layname laycol); = Change Nested Layer's Color

  (setq

    layname (cdr (assoc 8 (entget (car (nentsel "\nSelect nested entity for its Layer name: ")))))

    laycol (getstring "\nColor to assign to that Layer: ")

  )

  (command "_.layer" "_color" laycol layname "")

  (princ)

)

 

That could be expanded to ask for and apply a linetype, if you normally change both, or a separate one could be made for any property you want to deal with one at a time, or if you always want to apply the same color to such Layers that you select, that could be hard-coded in without asking the User for it, etc., etc.

 

 

Kent Cooper, AIA
Message 7 of 10

claimed4all
Advocate
Advocate
This tmp layer filter is gold. Pure Gold! Thank you, I see many uses for this.
0 Likes
Message 8 of 10

Anonymous
Not applicable

Can you please post the full command? 

0 Likes
Message 9 of 10

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

Can you please post the full command? 


 

The CNLC command defined in Message 6 is "full" -- is that not what you're looking for?

Kent Cooper, AIA
0 Likes
Message 10 of 10

Anonymous
Not applicable

Yes thanks

0 Likes