A script can be ran at startup using the /b (on Windows) or -b (on Mac OS) command line switch.
Suppose that every time you begin a new drawing, you turn on the grid, set the global linetype scale to 3.0, and set layer 0 as your current layer, with red as the color. You can do this using a drawing template, but you could do it instead with the following script and store it in a text file called setup.scr.
grid on ltscale 3.0 layer set 0 color red 0
The first line turns on the grid. The second line sets the global scale for linetypes. The third line sets the current layer to layer 0 and sets its default color to red. The application assumes that in a script you want to use the command line version of the LAYER command rather than the palette version. The result is equivalent to entering -layer at the Command prompt. The fourth line is blank, ending LAYER.
You can open a drawing and run a script at startup using one of the following techniques:
You use the /b (on Windows) or -b (on Mac OS) command line switch to run a script file on a new or existing drawing file when the application starts up. This is done by using the following syntax:
executable_path drawing_name /b script_name
You can also specify the view that is displayed when the drawing opens by using the /v command line switch and the view name. The /b command line switch and the script file must be the last parameter listed.
executable_path drawing_name -b script_name
Including the file extensions .exe/.app, .dwg, .dwt, and .scr is optional. If the script file cannot be found, the application reports that it cannot open the file.
You can create a new drawing using the /t (on Windows) or -t (on Mac OS) command line switch with a specified drawing template before running a script file. The following syntax creates a new drawing using the MyTemplate.dwt file and then runs the script.scr script after the drawing is created:
executable_path /t MyTemplate /b setup
executable_path -t MyTemplate -b setup
If you want to use the default template for the new drawing, you can omit the /t or -t command line switch and the template file name.