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
Solved! Go to Solution.
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.
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
@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?
Regars,
DJ
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.
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.
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
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
@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
Can't find what you're looking for? Ask the community or share your knowledge.