Community
AutoCAD LT Forum
Welcome to Autodesk’s AutoCAD LT Forums. Share your knowledge, ask questions, and explore popular AutoCAD LT topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Merge Multiple Layers in AutoCad 2015LT

15 REPLIES 15
SOLVED
Reply
Message 1 of 16
Anonymous
4115 Views, 15 Replies

Merge Multiple Layers in AutoCad 2015LT

Hi all,

 

I need a little help.

I have a number of drawings that contain various layers named in an old way.

I need to merge these old layers into a new layer.

 

Here are some examples, in the same file that I would need to merge:

Old Layer 1 > New Layer 1

Old Layer 2 > New Layer 2

Old Layer 3 and 4 > New Layer 3

Old Layer 5 (remains as is, no merging required).

 

I can do this (rather tediously) using the LAYMRG command, but I have about 30 instances in a drawing to do, and I have about 100 drawings to do it in.

 

Ideally, I would like to create a reference table that contains what merges with what, and then call this with a scipt inside the drawing file.  I'm happy to open each drawing and run the script each time rather than batch run the script.

 

Can anyone help me work out a script to do this, as I am unfamilar with the scipt syntax (I will need to learn).

 

I did find an old script (possibly 2008), but it won't run because I think the old MergeLayers command is defunct in 2015LT.  I tried to substitiute for the LAYMRG command, but with no luck.

 

Any help would be very greatly appreciated 🙂

 

Cheers,

Glynn

 

15 REPLIES 15
Message 2 of 16
pendean
in reply to: Anonymous

There is no commandline version of LAYMRG so there is no automation options in LT.

FWIW LAYMRG is also a right-click option inside the LAYER command palette in modern LT versions: makes layer selection quicker IMHO.
Message 3 of 16
Anonymous
in reply to: pendean

Many thanks for the reply pendean, much appreciated.

 

I was hoping that that wasn't the answer though 😄

I know about the right-click, and that's how I will have to do it, but I'm really surprised there is no way to automate this.  Is it an LT limitation, so could it be done in full version?

 

The prevalence of layers and naming conventions in the UK BS1192 standards would make this feature REALLY useful indeed, so Im surprised there is no way to do it en-masse.

Message 4 of 16
pendean
in reply to: Anonymous

All part of the discounted pricing that is LT: Full AutoCAD, for more money, has the programming ability (with Lisp, VBA and C++) to overcome core command limitations. It also has STANDARDS command (and the DWS file type) that does more of what you actually want, aka conforming to 'standards'.

If you do this all day long it may well be worth the price you save in time doing it your method right now.
Message 5 of 16
Anonymous
in reply to: pendean

Understood pendean, thank you 🙂

 

We "personally" do not do this enough to worry about doing it again I suspect.  If I did, I would understand the risk better and plan for it in the early tsgaes of the project better.

 

I am seemingly cursed by budget restraints and commercial reality.  I better get my medical insurance prepared for the repetitive strain injury I am about to receive 🙂

 

Thanks for your time sir!

Glynn

Message 6 of 16
drjohn
in reply to: pendean


@pendean wrote:
There is no commandline version of LAYMRG so there is no automation options in LT.

FWIW LAYMRG is also a right-click option inside the LAYER command palette in modern LT versions: makes layer selection quicker IMHO.

Are you sure?  I have 2012LT at work and it has LAYMRG (at the command line ... no buttons or menu ... all keyboard) and it is functional.

 

Am I violating EULA?  Smiley Wink

 

 

Regars,

DJ

 

Message 7 of 16
pendean
in reply to: drjohn

Does it let you type names of old and new layers in LT2012? Not here in LT2016 and I did not think the OP wanted to screen-pick objects that may or may not be on the correct source and destination layers.

Let us know.
Message 8 of 16
Anonymous
in reply to: pendean

Thanks pendean and drjohn.

I can use the LAYMRG command in the command window and type N for layer name (rathert than picking objects), then enter the actual layer name I want to merge, then type the layer to merge it to.  Ive successfully done that in the 2015LT command window.  It's tedious though.

 

I tried to create a copy/paste for the Command line, like:

 

LAYMRG

N

OldLayer1

OldLayer2

OldLayer3

ESC

N

NewLayer1

Y

 

But that wasn't working well... as I didn't fully get the command line syntax for button use and keystrokes.

 

I am currently using the Layer Properties Manager, select the old layer(s) - in this case I have to select up to 3 old layers in some instances, then right click and select Merge Selected Layer(s) to ...

Then just select the new layer I want in the dialog box.

 

Its just that this takes a while, and I am sure there MUST be a shortcut of sorts.

Message 9 of 16
Anonymous
in reply to: Anonymous

As an example.  If I paste this into the command line:

 

LAYMRG
N
OLDLayer1

 

It stops at the OLDLayer1 part because a dialog box appears.  I can't get the Command Line text to cancel the box, despite the fact that OLDLayer1 actually gets pasted into the command line ready...  the intervention of the dialog box seems to be the issue.

Message 10 of 16
Anonymous
in reply to: Anonymous

I've managed to get this working in AutoCad 2015LT. This works perfect!

I have objects on OLDLayer 1, 2 and 3.
When I run the script, all the objects are on the NEWLayer.

 

In the script below, substitute <CR> with blank lines (no spaces) - really important.

Initially the script adds any layers (-LAYER) that might not exist in the original file so the script doesn't break.  If the layers already exists it doesn't get overwritten, so don't worry.  It then defaults the current layer to 0, as you cannot merge a layer you created.

Then it merges everything as the script.

-LAYER
M
OLDLayer4
<CR>
<CR>
<CR>
-LAYER
M
OLDLayer3
<CR>
<CR>
<CR>
-LAYER
S
0
<CR>
<CR>
<CR>
-LAYMRG
n
OLDLayer1
<CR>
n
NEWLayer
y
<CR>
<CR>
-LAYMRG
n
OLDLayer2
<CR>
n
NEWLayer
y
<CR>
<CR>
-LAYMRG
n
OLDLayer3
<CR>
n
NEWLayer
y
<CR>
<CR>
-LAYMRG
n
OLDLayer4
<CR>
n
NEWLayer
y
<CR>

All of that is in a Notepad file with a .scr suffix rather than a .txt suffix.
I type SCRIPT at the command line, select the .scr file and bingo. Now I just need to correctly populate my .scr file with the actual layer names.

AWESOME!
Cheers,
Glynn

Message 11 of 16
Anonymous
in reply to: Anonymous

One last parting shot for anyone finding this thread later and having the same trouble. I've just created my actual script on a current drawing and it worked flawlessly after the following caveat:
Any layers that have spaces in the layer names should be formatted as follows in the script

When using -LAYER, layers containing spaces should be enclosed in quotation marks:
-LAYER
M
"OLD Layer 4"

When using -LAYMRG, you DO NOT need the quotation marks.
-LAYMRG
n
OLD Layer 1
<CR>
n
NEWLayer

Thanks, Glynn

Message 12 of 16
drjohn
in reply to: pendean


@pendean wrote:
Does it let you type names of old and new layers in LT2012? Not here in LT2016 and I did not think the OP wanted to screen-pick objects that may or may not be on the correct source and destination layers.

Let us know.

Oops ... didn't check far enough.  Selecting by name at the cmd line displays a dialog.

 

But apparently it will pass it in a script cause the OP has it worked out now.

 

 

Regards,

DJ

 

Message 13 of 16
pendean
in reply to: Anonymous

Thanks for sharing: your script wroks well in LT2016 as well.

 

I love learning new tricks.

Message 14 of 16
Anonymous
in reply to: pendean

Excellent 😄

Message 15 of 16
eidam655
in reply to: Anonymous

you rock!
I also found out you can merge multiple layers into one in one step, when you use the following block:

-LAYMRG
n
OLDLayer4
n
OLDLayer5
<CR>
n
NEWLayer
y
<CR>

Also it is important to use the correct encoding when saving the file, but only if you have special characters in your layer names (like ü, ä etc.... Windows 1252 worked fine)
Message 16 of 16
RSomppi
in reply to: eidam655

Isn't it easier to do it within the layer manager as stated above?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Technology Administrators