Creating multiple duplicate layers

Creating multiple duplicate layers

lbellino4
Collaborator Collaborator
509 Views
2 Replies
Message 1 of 3

Creating multiple duplicate layers

lbellino4
Collaborator
Collaborator

Hello.

Is there a way to duplicate a group of layers in the layer manager? And if yes, what is the best way to update the layer name text for these duplicate layers at the same time with the same change? What I'm trying to do is copy all the layers I've highlighted in the image attached and then change out the text that says, "CS301" to "CS302".  Thanks in advance for the help.

 

layers.JPG

0 Likes
510 Views
2 Replies
Replies (2)
Message 2 of 3

leeminardi
Mentor
Mentor

The following is a kludge but it works.  I'm sure that someone can offer a more straightforward solution.

 

The first task is to get a list of the layer names you want to create.  To do this you can give the -layer command followed by ? then *

For example,  if your drawing contains layers layer1 through layer5 the result would look like this.

leeminardi_0-1706032242685.png

Let's say that you would like to create new layers named "LayerNew1" though "LayerNew5".

Select and copy to the clipboard the 5 lines containing the layer properties and paste them into MS Word or Notepad++. Use the Replace function to make your changes to the layer names.  For exaple, replace "er" with "erNew". Now position the cursor before the quote mark " of the first line and hold down the Alt key. Then drag down selecting just the names of the layers you want to duplicate.  Holding down the Alt key enables the partial selection of a row.  Use Ctrl-C to copy the selected text to the clipboard.

leeminardi_2-1706032845479.png

In AutoCAD type the follwing and then give Ctrl_V to paste the names for the new layers.

(setq a (list 

Finish this step with two closing parantheses )).

Now run the lisp program MakeLayers

(defun c:MakeLayers (/ n i)
  (setq	n (length a)
	i 0
  )
  (while (< i n)
    (command "-layer" "m" (nth i a) "")
    (setq i (+ i 1))
  )
  (princ)
)

Enjoy!

 

 

 

 

 

lee.minardi
0 Likes
Message 3 of 3

ВeekeeCZ
Consultant
Consultant

Two tips.

If you have a few of them, a nice trick is to rename the layer (F2 could help) and confirm the name by , (comma) instead of enter.

If you have plenty of layers to rename, open another copy of your file, use Rename, and then copy objects back to the main drawing and remove them (or Design Center to copy just layers).

0 Likes