Overview of Command Scripts (Concept)

AutoCAD

 
Overview of Command Scripts
Concept Procedure Quick Reference
 
 
 

A script is a text file with one command on each line.

You can invoke a script at startup, or you can run a script during a work session by using the SCRIPT command. A script also provides an easy way to create continuously running displays for product demonstrations and trade shows.

The BACKGROUNDPLOT system variable must be set to 0 before a script can plot multiple jobs.

You create script files outside the program using a text editor (such as Microsoft® Windows® Notepad) or a word processor (such as Microsoft Word) that can save the file in ASCII format. The file extension must be .scr.

Each line of the script file contains a command. Each blank space in a script file is significant because SPACEBAR is accepted as a command or data field terminator. You must be very familiar with the sequence of prompts to provide an appropriate sequence of responses in the script file.

NoteKeep in mind that prompts and command names may change in future releases, so you may need to revise your scripts when you upgrade to a later version of this program. For similar reasons, avoid the use of abbreviations; future command additions might create ambiguities.

A script can execute any command at the command prompt except a command that displays a dialog box. In most cases, a command that displays a dialog box has an alternative version of the command that displays command prompts instead of a dialog box.

Script files can contain comments. Any line that begins with a semicolon (;) is considered a comment, and it is ignored while the script file is being processed. The last line of the file must be blank.

All references to long file names that contain embedded spaces must be enclosed in double quotes. For example, to open the drawing my house.dwg from a script, you must use the following syntax:

open "my house"

The following commands are useful in scripts:

'DELAY

Provides a timed pause within a script (in milliseconds)

'GRAPHSCR

Switches from the text window to the drawing area

RESUME

Continues an interrupted script

RSCRIPT

Repeats a script file

'TEXTSCR

Switches to the text window

When command input comes from a script, it is assumed that the settings of the PICKADD and PICKAUTO system variables are 1 and 0, respectively; therefore, you do not have to check the settings of these variables.

A script is treated as a group, a unit of commands, reversible by a single U command. However, each command in the script causes an entry in the undo log, which can slow script processing. If you like, you can use UNDO Control None to turn off the undo feature before running the script, or you can write it at the beginning of the script itself. Remember to turn it back on (UNDO Control All) when the script is finished.

The script that is running stops when another script command is invoked.