Script writer command input

Script writer command input

MrMuscl3
Advocate Advocate
649 Views
6 Replies
Message 1 of 7

Script writer command input

MrMuscl3
Advocate
Advocate

Been using Lee Mac's Script Writer few times every year. It troubles my mind that I don't totally (or very much at all) understand how to create scripts with working command queue's.

 

Example of very simple script which I've used to clean drawings: _.open *file* _.purge _all * _no _.qsave _.close

 

In above script, some kind of selection is made with *. Parameter/input * for this selection I found from somewhere, but have no idea who came up with the solution and where the information was found. Back then didn't even know what it selected.

 

Set the autocad logging function on and by reading the log it became clear what function * had in here. For some reason autocad commandline did not anymore print information when running scripts. Remember it before did 🤔 Therefore the logging.

 

Enter type of unused objects to purge [Blocks/DEtailviewstyles/Dimstyles/Groups/LAyers/LTypes/MAterials/MUltileaderstyles/Plotstyles/SHapes/textSTyles/Mlinestyles/SEctionviewstyles/Tablestyles/Visualstyles/Regapps/Zero-length geometry/Empty text objects/Orphaned data/All]: _all Enter name(s) to purge <*>: * Verify each name to be purged? [Yes/No] <Y>: _no Deleting block "xxx1".

 

Repeating the same process with autocad GUI: purge -> purge all, the following prompt appears. In no way does this correspond to what autocad wants from the script after "_.purge _all". GUI wants me to answer a question purge this/all/skip, while the script asks filenames.

 

MrMuscl3_0-1746558205265.png

 

In Lee Mac's guide following is written: . (period) - Non-redefined command prefix: this prefix is used to account for commands that have been redefined, ensuring that the original standard command is used and not a redefined version.

 

My current theory is that when period is used before commands, these commands are then run in simplistic way where no prompts appear, like one seen in image above. Correct?

 

If, then all commands which include prompts must have unique (not the same as when run through GUI) promptless outputs when ran in this simplistic way. Correct?

 

If, then to create these scripts, user has to know how the application replies for used command and what selections it offers. Otherwise there's no way to know how to write these. Can somebody guide me to place where this kind of information is available? Other guides are also welcome!

 

Did not yet test, but one possible way to test autocad outputs for different commands could be to run incomplete script with logging on (LOGFILEON) and then try somehow solve the mystery from printed log. Not sure if there would be enough information though. This sounds quite painful, there must be easier way 🤔

 

Message became quite long, but hopefully people reading this will find it and the replies helpful 🙂

AutoCAD 2025
0 Likes
650 Views
6 Replies
Replies (6)
Message 2 of 7

cadffm
Consultant
Consultant

Hi,

 

my try:

 

Feedback/Log

I do not check the tool now, but my first idea is: Set CMDECHO to 1 and test it again!

 

*

The first * hit in your script is *file*, what is special and explicit for Lee Macs Script writer (nothing from AutoCAD native),

you read about it in LeeMacs documentation or you copy&use it from another place.

https://lee-mac.com/scriptwriter.html

The second * hit was just the answer for Acad Purge prompt - what to purge.

 

>>GUI wants me to answer a question purge this/all/skip, while the script asks filenames

No,

In your Script is the same question and you answering with N = NO

(The N after the last *)

>>> Verify each name to be purged? [Yes/No] <Y>: _no

The Script don't ask for filenames at this point, the point where Acad ask for a filename is after starting the OPEN command - like it is the same onn GUI. 

Start OPEN and Acad will ask for a filename.

 

>>like one seen in image above. Correct?

No,

the period is for, what LM wrote. It is possible to redefine commands in Acad.

For example, I can redefine your LINE command. 

If you start LINE command, it will create a Circle for example!

If you start .LINE, it will create a line as usual.

The Period forcing Acad to use the original native command definition.

 

>>user has to know how the application replies for used command and what selections it offers.

Always, because you have to "answer" all prompts.

 

>>Can somebody guide me to place where this kind of information is available? 

In your AutoCAD, start the command and take a look, write down your needed input.

Directly! Because you will not SEE all your inputs in Textlog (you don't need LogFile, [F2] is enough & quicker.

 

>>This sounds quite painful, there must be easier way

Yes, painful - but the best way to learn the commands!

More often you used a command (for scripts or macros), less you need to take a look .

Also a view to the command documentation can help, but the best is to do a 1:1 test in your commandline.*!

Easier? Out there are some non-AutoDESK pages with command and options,

but these will not help you, if you are not familiar with the commands.

Think about Command with nested options and goto jumps between them,

it is not possible to write all needed informations in a way you need.

 

*! Attention

Some commands are acting different between manually input in commandline and running by automation, like macro script or (send)commands!

 

So for some commands, you can not use the 1:1 workflow from commandline,

you have to test by macro script ir (send)command!

For example: Command -INSERT will acting different!

 

Ignore all following, I am writing by mobile and can not edit/delwte this quotes

 

 

 


 

 

 

In Lee Macs guide following is written: . (period) - Non-redefined command prefix: this prefix is used to account for commands that have been redefined, ensuring that the original standard command is used and not a redefined version.

 

My current theory is that when period is used before commands, these commands are then run in simplistic way where no prompts appear, like one seen in image above. Correct?

 

If, then all commands which include prompts must have unique (not the same as when run through GUI) promptless outputs when ran in this simplistic way. Correct?

 

If, then to create these scripts, user has to know how the application replies for used command and what selections it offers. Otherwise there's no way to know how to write these. Can somebody guide me to place where this kind of information is available? Other guides are also welcome!

 

Did not yet test, but one possible way to test autocad outputs for different commands could be to run incomplete script with logging on (LOGFILEON) and then try somehow solve the mystery from printed log. Not sure if there would be enough information though. This sounds quite painful, there must be easier way 🤔

 

Message became quite long, but hopefully people reading this will find it and the replies helpful 🙂


 

Sebastian

Message 3 of 7

cadffm
Consultant
Consultant

One info more

About your PURGE sample and general.

 

If a command (with dialog windows) has a brother command for commandline-dialog,

Like command LAYER or PURGE (commands -LAYER and -PURGE),

Acad will use the commandline version if started in automation!

 

Manually you start PURGE command, but in macro script or (send)commands, Acad will start -PURGE instead PURGE!

If you want to compare your Script vs Manually input, you need to compare 

Script run with command -PURGE !!

 

You should write/use command  -PURGE in your script too,

this way it is more clear for you.

 

 

Sebastian

0 Likes
Message 4 of 7

paullimapa
Mentor
Mentor

Precede commands & prompts with underscore to execute AutoCAD's native language command version (which is English ). This way it does not matter as to what AutoCAD language version the user is running ie:

_COPY _ALL

Precede a command with a period incase it's been undefined ie:

_.COPY

Precede a command with a hyphen because some AutoCAD commands when invoked this way will bypass the gui ie:

_.-PURGE

_.-PLOT

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 5 of 7

Simon_Weel
Advisor
Advisor

For Script Writer, the documentation is lacking? There's no explanation for those stars, for example.

For plain AutoCAD scripts, the help text is a good start, I guess: AutoCAD 2024 Help | Streamline Tasks with Scripts | Autodesk

 

As for AutoCAD commands starting with a period, for example .line, this means AutoCAD will execute the Line command, even if the Line command has somehow been redefined.

The underscore prefixing a command like _purge indicates AutoCAD should use the English name for the command instead of the localized name. See AutoCAD LT 2025 Help | About Command Macro Strings | Autodesk

There are some commands that can both use the GUI or command line. For example Purge will call up the GUI version. Commands prefixed with a hyphen like -Purge will call up the command line version.

 

0 Likes
Message 6 of 7

paullimapa
Mentor
Mentor

For Script Writer, the documentation is lacking? There's no explanation for those stars, for example.”

i beg to differ since the explanation of *file* is pretty clear in the link provided in OP:

https://lee-mac.com/scriptwriter.html


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 7 of 7

Simon_Weel
Advisor
Advisor

You're right. The 'lone star' after the Purge command had me puzzled; I now realize it's part of Purge.

0 Likes