This is the second of three blogs explaining how to manage system variables.
-
This blog demonstrates a level of automation to change the variables and store them in toolbars.
Scripts
When saving the variable settings to an external file from the Systems Variable dialog box, you can save either a filtered list (by using the search with wildcards) or a selected list by selecting multiple variables (using the <CTRL> or <Shift> key to select more than one). If only one variable is selected, then all will be saved, as shown.
You have the option of file formats, as shown:
-
SVF is for reading (restoring) variables in the Systems Variable dialog box.
-
SCR is for restoring the variables through the AutoCAD Script command.
Script Files
To use the script file, type Script in the Command Line, then browse to the script file (with a *.scr extension). Select the file to open it. AutoCAD reads each line as if it were typed in at the command line. It skips any line that starts with a semi-colon (;) – this usually precedes variables that are read-only and cannot be changed.
You can also develop macros using such script formats. Similar to scripts, a macro is a series of keystrokes executed when the macro is launched. Scripts run the commands from the contents of a text file whereas macros run the commands from a text string within the macro, which is stored in the program.
Macros can be defined as commands through the CUI interface where the following can be done, as shown:
-
Create a new command.
-
Search for commands (which then can be edited).
-
Name the new command.
-
Create the macro:
a. Type in the commands exactly as you would in the command line.
b. “^C^C” means <CTRL> C, <CTRL> C, which cancels any ongoing command.
c. A space acts the same as an <Enter> key.
-
Assign an icon, or button image, to the command.
-
Drag the new command into the Quick Access bar.
Note: you can also drag the command directly to the Quick Access Bar while it is listed in the CUI interface, as shown.
With the new command created, you can now type it in the command line to be executed. For example, you can create a new command “FILEDIA-ON”. The macro would be
“^C^CFiledia 1 ”
This would cancel previous commands, invoke the FILEDIA system variable and set it to 1. Note the space at the very end, which acts as pressing the spacebar, which in AutoCAD is the same as the <Enter> key.
The macros / commands can be added to other toolbars. You can create a new toolbar directly in the CUI interface through the right-click menu, as shown. Then you can drag any combination of commands into the toolbar. For example, you may have a toolbar named “System Variables”, and in it a series of macros, some for turning on variables and others for turning off variables.
Conclusion
Creating macros is a great way to streamline your AutoCAD workflows. With a bit of imagination, you can string together a series of commands and set variables. They can be added to the Quick Access Toolbar, or you can create other toolbars to house these macros.
About the Author
Follow on Linkedin More Content by Jeff Morris