How to "escape" a command in a script file to continue with next command.

How to "escape" a command in a script file to continue with next command.

Anonymous
Not applicable
10,649 Views
13 Replies
Message 1 of 14

How to "escape" a command in a script file to continue with next command.

Anonymous
Not applicable

I am using -layer command and -plot. The problem is -layer will continue forever until you cancel it, i am not able to find a script command to do this. If i use (command) it kills the whole script which is not what i want to do.  The picture below shows where my script gets stuck, which input in the command line would end the -layer command without using "(command)".

 

 

Script.PNG

I have seen numerous posts about this and none with an actual answer, if there is another work around to this I am happy with that too. Thanks

 

0 Likes
Accepted solutions (2)
10,650 Views
13 Replies
Replies (13)
Message 2 of 14

cadffm
Consultant
Consultant

Acad ask you for an OPTION, if you dont want any Option, choose nothing (Hit ENTER)

 

 

in Macros ";"

in Scripts "new line"

 

 

Sebastian

Message 3 of 14

Anonymous
Not applicable

Both of those are invalid commands

Message 4 of 14

Anonymous
Not applicable

In lisp (command) just use ""

For example to make new layer:

(command "_Layer" "_n" "ziele_o2k" "")

 

0 Likes
Message 5 of 14

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

Both of those are invalid commands


The "new line" in a Script-based approach was meant not as text saying that, but literally, as a new line, or a line that consists of nothing other than Enter to go on to the next line.  For example:

 

....

_.-LAYER _Set WHATEVER

 

_.-PLOT

....

 

The empty line there has meaning  [unlike in an AutoLisp file], containing as it does the Enter to go to the next line, and will conclude your Layer command without cancelling the whole Script.

Kent Cooper, AIA
Message 6 of 14

Anonymous
Not applicable

Okay so that seems to work some of the times, if put a lot of lines in between the -layer and -plot command then it works. Is that the only way? If not enough space then -plot ends up in the command for -layer.

 

Message 7 of 14

cadffm
Consultant
Consultant

@Anonymous - nothing to do wit guess.

Thats the way how to..

 

 

Start your Acad and start the command. Command LAYER in Scripts are translate to the commandline-version -LAYER,

in could use LAYER for your script, but i use the commandlineversion call which i use to test it by Hand, type in:

-LAYER

then hit [Enter]

write down on paper:

-LAYER[enter]

 

Acad asking for an Option, try color and type in:

COLOR

then hit [Enter]

write down on paper:

COLOR[enter]

 

for example color 6:

Acad asking for a color:

6

then hit [Enter]

write down on paper:

6[enter]

 

Acad asking for Layer(s) to apply the color 6, for our example we use Layer"0"

0

then hit [Enter]

write down on paper:

0[enter]

 

Acad asking for an Option, we only want to exit the command an like the LINE command and hundred commands more, we answer without an option and hit only Enter:

hit [Enter]

write down on paper:

[enter]

 

 

Now you wrote down:

-LAYER[enter]COLOR[enter]6[enter]0[enter][enter]

 

Now you can create a Script, because NOW you know how the command/workflow works. Change [enter] to an <newline> in your Script:

#####################

-LAYER

COLOR

6

0

 

 

#####################

 

 

Or if you want to create a Menumacro, change [enter] to ";"

-LAYER[enter]COLOR[enter]6[enter]0[enter][enter]

-LAYER;COLOR;6;0;;

 

Or if you want to controle the commandline from Lisp-command, set all inputs in ""

(command "-LAYER" "COLOR" "6" "0" "" "")

---------------------

In yout Textwindow [F2]

Command: -LAYER<<enter>>

Current layer:  "0"
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: COLOR<<enter>>

New color [Truecolor/COlorbook] : 6<<enter>>

Enter name list of layer(s) for color 6 (magenta) <0>: 0<<enter>>
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]:<<enter>>

Command:

Sebastian

0 Likes
Message 8 of 14

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

Okay so that seems to work some of the times, if put a lot of lines in between the -layer and -plot command then it works. Is that the only way? If not enough space then -plot ends up in the command for -layer.


I should probably have made it explicit that the one  empty line in my example will do it if what you have just done is to Set a Layer current, because the prompt that follows that has <exit> as the default option that you will get if you use Enter [oxymoronic, isn't it?].  Yes, you do need different numbers of Enters [see @cadffm's procedure], depending on exactly which options you've been using, to conclude the command.  If you get into Layer stAtes, it can be even more than the two in their example.  As suggested, do it manually with the actual options you'll be using, to find out exactly what you need to feed to the command and when.

Kent Cooper, AIA
Message 9 of 14

Anonymous
Not applicable

Layer
S
Layer2
Freeze
*

PLot
Y
Model
\\XXXXXXXX
Letter
I
P
N
E
F
0.00,0.00
Y
.
Y
A
N
N
Y

 

 

Layer
T
*
S
Layer3
Freeze
*

PLot
Y
Model
\\XXXXXXXX
Letter
I
P
N
E
F
0.00,0.00
Y
.
Y
A
N
N
Y

 

 

 

That is the script I am trying to run and I am really having issues with autocad not ending certain commands and taking inputs from one command and using it for another. For example plot command is being taken as an input for a layer command. I need something that ends command because using "enter" is not consistent. I am literally entering spaces or deleting spaces to make it work half of the time. I have like 30-40 layer pages per drawing I want to print. I want to be able to put it in excel change the layers names and putting it back in notepad.scr file and executing.

0 Likes
Message 10 of 14

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

...
Freeze
*

PLot
....

 

... I am really having issues with autocad not ending certain commands and taking inputs from one command and using it for another. For example plot command is being taken as an input for a layer command. I need something that ends command because using "enter" is not consistent. ....


Yes, PLOT is being taken as input for the Layer command, because you're still in that.  You just need an Enter [empty line] to complete the Layer command before starting the Plot command [two places]:

....

Layer2
Freeze
*

 

PLot

....

 

I don't understand the ' "enter" is not consistent ' part.  Just do as suggested a few posts back -- do the command manually, and keep track of exactly what inputs are asked for and supplied and in what sequence, including Enters to accept defaults [including especially to accept the default <exit> option to conclude the command], and build those all into the Script.

Kent Cooper, AIA
0 Likes
Message 11 of 14

cadffm
Consultant
Consultant
@Anonymous
Create your Script like my Example and you will be happy, it is better than try/guess&error&asking others.

One thing more/again:
After creating script, run the script and open your Textscreen [F2], most of problems you can read there.

Your Version should wrote a Log like this (not literally)
Layer [new make lock....]: PLOT
unknown Option..
Layer [new make lock....]: Y
unknown Option..
And so on. (Sorry, i am not sitting on acad at this time)

Sebastian

0 Likes
Message 12 of 14

Anonymous
Not applicable

When i said the enter part is not consistent, i meant that number of lines between last command of layer and the new plot command is not consistent. I have sometimes either add more lines or delete some. If it was consistent then that would be great.

 

I did do the command manually to begin with in Autocad with -layer and -plot, then copied all of that in notepad to make it into a script and then deleted the comments.

 

 

The end goal is to put it all into excel change the layer names on there for different drawing i want to use it on and then paste in notepad again to run the script.

0 Likes
Message 13 of 14

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

When i said the enter part is not consistent, i meant that number of lines between last command of layer and the new plot command is not consistent. I have sometimes either add more lines or delete some. If it was consistent then that would be great.

....


It shouldn't be expected to take the same number of Enters in a Script in all circumstances, because it doesn't take the same number of Enters to conclude the Layer command in all cases -- it depends on what option is used at the end.

 

For example, if the last option used is assigning a color to the current Layer, then after giving it the color, you need an Enter to accept the current Layer name as the default to which that color is to be assigned, and  another Enter to conclude the command.  But if the last option is Setting a Layer current, then after giving it the Layer name, only the one  final Enter to conclude the command is needed.  If the last option is to define a new Layer stAte  with the current conditions, and if you don't change any of the offered states, you need three to get out.  Etc., etc.

 

A possible source of apparent  inconsistency might be if you have any space(s)  [which you won't be able to see] on any of those blank lines.  A space is equivalent to Enter under some  prompt conditions in the Layer command, but not  under others [such as when asking for a Layer name, since those can include spaces].  If you make sure all blank lines are really empty, you shouldn't have any difficulty when there are appropriate numbers of blank lines for the concluding option in each case.

Kent Cooper, AIA
0 Likes
Message 14 of 14

cadffm
Consultant
Consultant
Accepted solution
@Anonymous
Kent answered very well, the only problem point is
a) you did not write down your inputs exactly
or
b) you did not write them exacty to your texteditor.

At the beginning of writing macros, scripts (or programming) it is really hard, because there is no space for typos.

Do the steps again, not in hurry, and you will find your misstakes.
F2 can be very useful to find them after running a test.

Thumbs up - we will help you, but doing&learning is your part 🙂

Sebastian

0 Likes