Creating a script file can be an easy way to automate tasks in AutoCAD based applications. Scripts can be as simple as a couple of lines to change a variable, or complex to the point of generating an entire template’s worth of background settings. Anything you can manually enter via the keyboard can be pre-programmed into a script, saving you time and energy when going through repetitive tasks.
For simple script files, a basic notepad type application will do, but for longer scripts, or scripts with repetitive commands, Excel® and other spreadsheet applications can be a big advantage.
Leveraging AutoFill, formulas and built-in sequencing can be a huge time saver. Here are some tips for creating scripts using a spreadsheet.
- Each Cell represents a keyboard-based command or option
- Each Row represents individual commands, and sequential cells are options in that command
- Add a ‘ symbol at the beginning of cells that include other symbols
- Use Base commands that being with a “-“ symbol to trigger keyboard entry
- Leave the first cell blank cell to repeat a command in consecutive rows
- AutoFill or copy and paste to quickly repeat command options
- Test the command string manually in AutoCAD and repeat keyboard entry in cells of each row
- Copy and paste numerical data or use formulas to fill in X, Y, Z and other values.
- SaveAs a Text(Tab Delimited) .TXT file and change the extension to .SCR to create the script
Here’s a quick example of a script file that creates multiple layers and sets their color automatically. The Base command -Layer is being used to create a New layer with a user defined name, and a Color is also being set for that layer in process. A ‘ symbol was used ahead of -Layer to avoid any automated formula errors in Excel®.
AutoFill was used for the second and fourth rows, and Copy/Paste was used for the third and fifth rows. The more rows or columns you use, the more you can leverage use of a spreadsheet.
Exporting to a Tab Delimited text file produces this:
And changing the .TXT to a Script (.SCR) file and dropping into AutoCAD produces this:
Although this was a basic script file example, this workflow can be expanded to work with any type of repetitive keyboard entry. An added bonus is that the spreadsheet can be edited quickly and easily and re-exported to update the script file.
Next time you run into some repetitive tasks in AutoCAD, consider using a spreadsheet to quickly generate a script file.
About the Author
Follow on Linkedin More Content by Matt Miyamoto