Jump to content

how do I create a simple script to copy everything from one layer to a new layer?


four_by_ken

Recommended Posts

I need to take everything that is on a layer and copy it to a new layer. Basically make an identical layer copy. This will be done on more than 70 drawing packages... totally more than 6000 files total.

 

The original layer will remain unchanged... the new layer will then be updated, without anything being done to the old layer.

 

That way a toggle between layers will show original vrs. new.

 

 

Thanks

Ken

Link to comment
Share on other sites

If you want to go for a shotgun method for the entire drawing, save the drawing under a different name then xref the old drawing into the new. I'd stop there.. but you could always bind & let acad tag the dwg name inront of the layers - boom new layer coppies of everything in the drawing.

 

Personally I'd set the original file in an Archive directory then just xref it from there that way I could unload the drawing & not have the overhead while I'm working.

Link to comment
Share on other sites

I dont think this will get what I what to do. I need to have only one drawing for this. So, xref will require another drawing to be out there somewhere... which I cannot have.

 

I need to have the original drawings on say layer 1. And this I will freeze and hide. But, before I do that, I need to copy it to layer 2. And this will become the working layer, where changes will be made without any effect to the original on layer 1.

Link to comment
Share on other sites

I would either xref it or _WBLOCK it out to a new file and insert it as a block.

 

Just so you will know, AutoCAD 2008 has the command "Copy Objects to New Layer". There may be a LISP out there somewhere.

Link to comment
Share on other sites

I dont think this will get what I what to do. I need to have only one drawing for this. So, xref will require another drawing to be out there somewhere... which I cannot have.

 

I need to have the original drawings on say layer 1. And this I will freeze and hide. But, before I do that, I need to copy it to layer 2. And this will become the working layer, where changes will be made without any effect to the original on layer 1.

Bind the xref it will combne the 2 drawings. If you make sure that you chose the bind option rather than the insert option AutoCad will add the xref name infront of all its layers.

 

So what you'd do is:

1) In file explorer make a copy of your drawing & rename it. pick a short name like Orig.dwg

2) Now open the original file & xref the Orig.dwg in.

3) bind the xref using the BIND setting

4) delet the now un-needed orig.dwg

 

5) rinse & repeat

 

Autocad will create new layers for all of the layers in the Orig.dwg calling them "Orig|layerx" "Orig|layery" etc...

 

Now if you want eerything on one layer that's a little more troublesome.

Link to comment
Share on other sites

Here's a short lisp routine to do that. You could set it up to automatically load (and maybe run) when you open a drawing. Test it first :)

 

(defun c: c2lay ()
  (setq NewLyr "NewLayerName");;edit to suit
  (setq ExLyr "ExistingLayername");;edit to suit
  (setq ExStuff (ssget "_X" (list (cons 0 ExLyr))));;selection set of everything on layer
  (command "layer" "m" NewLyr "");;creates/sets layer
  (command "copy" ExStuff '(0 0) "");;creates a copy on same layer
  (command "chprop" ExStuff "" "LA" NewLyr "");;changes orig to new layer
  (princ);clean exit
)

Link to comment
Share on other sites

It was much easier than I expected. Here is what I did.

 

open the drawing

move everything to 'Layer 1"

purge all

create layer 2

copy everything to Layer 1 in the exact same location on layer 1

'change' previous selection (all that I just copied) to Layer 2

turn layer 1 off

turn layer 2 on

save

 

 

Done deal. :thumbsup:

 

Routine takes about 30 seconds on 200 pages.

Link to comment
Share on other sites

Just wrote a simple step by step xxxxx.scr file and ran it in AutoCAD.

 

open

xxxx.dwg

change

all

 

layer

layername

 

ect etc ect ect

 

Did you use anything to create or make sure the layer you were moving to was there?

Link to comment
Share on other sites

  • 8 years later...
I found very useful the lisp routine on this thread. But does it work in autocad 2016. did anyone check it?

 

In the time it took you to post your question you could have downloaded then tested the lisp routine thereby answering the question for yourself. The worst that can happen is that it fails to execute properly. Test on a copy of one of your drawings and not the original.

Link to comment
Share on other sites

In the time it took you to post your question you could have downloaded then tested the lisp routine thereby answering the question for yourself. The worst that can happen is that it fails to execute properly. Test on a copy of one of your drawings and not the original.

 

Of course I did, my aim was to ask if anyone has experimented the same issue and if there is a solution for it. I think is one of the most demanded routine for autocad and it appears doesnt exists. Using copylayer is very annoying bcz you first have to use quck select to copy the existed items.

Edited by darwinland
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...