laymrg script

laymrg script

mpizzino
Participant Participant
794 Views
10 Replies
Message 1 of 11

laymrg script

mpizzino
Participant
Participant

Does anyone have an idea how to write a laymrg script with the code on a single line as opposed to several lines?  The problem I'm having is, when the script runs the old layer and the two spaces after it, it thinks the rest of the string is part of the layer name.  Is there any way to force the script to stop reading the layer name after "old layer"?  I've tried everything I can think of to force it to read the layer name correctly, to no avail.  The ultimate goal is to laymrg survey layer from a surveyor to our company standard layers.  I want to copy all the survey layers to excel then set up a second tab that references the survey layer into the script line:

 

;Survey Layer  Company Layer 
-LAYMRG     
Nold layer Nnew layerY

 

Copying the code to notepad gives me this ( _.-LAYMRG N old layer  N new layer Y) but it gets hung after "old layer" because it thinks everything after "old layer" is part of the layer name. 

 

Thanks

 

0 Likes
Accepted solutions (1)
795 Views
10 Replies
Replies (10)
Message 2 of 11

JTBWorld
Advisor
Advisor

Try enclose the layer names within double quotes. 


Jimmy Bergmark
JTB World - Software development and consulting for CAD and license usage reports
https://jtbworld.com

0 Likes
Message 3 of 11

mpizzino
Participant
Participant

Unfortunately quotes and double quotes around layer names yield the same hang up after the first layer name:

 

_.-LAYMRG
N "g-e-minor" N "V-TOPO-MINR" Y

mpizzino_0-1645542934577.png

 

_.-LAYMRG
N ""g-e-minor"" N ""V-TOPO-MINR"" Y

mpizzino_1-1645543044535.png

 

 

0 Likes
Message 4 of 11

JTBWorld
Advisor
Advisor

Here’s something I used long time ago:
(defun layermerge (oldlay newlay)
(if (tblsearch "layer" oldlay)
(progn
(command "._-layer" "_u" oldlay "")
(if (tblsearch "layer" newlay)
(progn
(command "._-layer" "_u" newlay "")
(command "._laymrg" "_n" oldlay "" "_n" newlay)
(if (wcmatch (getvar "cmdnames") "*LAYMRG*")
(command "_yes")
)
)
(command "._rename" "_la" oldlay newlay)
)
)
)
)


Jimmy Bergmark
JTB World - Software development and consulting for CAD and license usage reports
https://jtbworld.com

0 Likes
Message 5 of 11

Kent1Cooper
Consultant
Consultant

@mpizzino wrote:

Does anyone have an idea how to write a laymrg script with the code on a single line as opposed to several lines?  ....

Can you process the Excel information in a way that gives you "real" Enters?  I think you need those to complete the Layer names, which in Script format I think means you need to move down to additional lines of code.

Kent Cooper, AIA
0 Likes
Message 6 of 11

mpizzino
Participant
Participant

I'm exploring the idea of adding carriage return into the blank cells that would other be the space in notepad.  So when its all copied from excel to notepad, it will be a return to the next line instead of a space (which moving one cell left to right is interpreted as a space when pasted into notepad.)

0 Likes
Message 7 of 11

LyleHardin
Advisor
Advisor

It's been a while for me, but doesn't a semicolon represent an Enter in scripts?

** EDIT **

@mpizzino  I'm giving this a whirl. Yes, I see what you mean. Interesting. I get the same errors. I have no answer at the moment.

 

 

0 Likes
Message 8 of 11

LyleHardin
Advisor
Advisor

Here ya go. Try making your spreadsheet export to a script file but make each line a LISP routine like this:

 

(command "-LAYMRG" "N" "border" "N" "C-RIVR-NEW")

 

So your excel file will have to have a bunch of columns with double quotes in them.

0 Likes
Message 9 of 11

mpizzino
Participant
Participant

Thank you for the response!

Replicating your suggestion -  (command "_.-LAYMRG" "N" "g-e-minor"  "N" "V-TOPO-MINR" "Y") is hanging on me after the second layer input.

 

mpizzino_1-1645580585786.png

 

0 Likes
Message 10 of 11

mpizzino
Participant
Participant
Accepted solution

With a little massaging this does the trick"

 

(command "_.-LAYMRG" "N" "g-e-minor" "" "N" "V-TOPO-MINR" "Y") 

 

Looks like this in excel:

(command"_.laymrg""N""g-e-major""""N""V-TOPO-MAJR""Y")

 

Now I can replicate the lines and use cell referencing in the layer cells.  Then copy the rows back to notepad.

0 Likes
Message 11 of 11

Kent1Cooper
Consultant
Consultant

@LyleHardin wrote:

It's been a while for me, but doesn't a semicolon represent an Enter in scripts?

....


In command macros, yes, but not in Scripts.

Kent Cooper, AIA
0 Likes