In this tutorial, Josh Modglin walks through what is a script and how to create a script for use within your company AutoCAD configuration. The instructor discusses how to write and load an AutoCAD script. In addition, Josh demonstrates writing and loading an AutoCAD script and shows how easy script creation is.
- [Instructor] Scripts really are simply taking what we type at the Command line and allowing us to write it into an external file, which then can be loaded at the right time to complete the same steps. And so scripting is really the beginning of customization or writing custom language files without having to learn a programming language. At the same time, it really speeds up monotonous work. So let's write a script.
I'm using a text file editor Notepad++ but any text file editor would work. And what we're going to do is we're first going to turn off a variable called Filedia and notice that I'm just typing the variable name in, I'm placing a space from the variable name and the variable value. And so a space as well as a Return or Enter tells the software that we've pressed the Return key.
It's the same as if we were working at the Command line. So the next line or the next command, we're going to create a new layer called Lynda and we're going to set that layer Lynda to being the current layer as well as the color of the layer to be three or green. We'll put in two empty lines or returns to kind of end the layer command and we'll go down and we'll zoom extents.
Again we'll start another line or new command and set our variable for Filedia back to one. One more Enter to complete that command. What you see here really is exactly what you would read from the Command line history we could almost copy and paste straight from the Command line history to create our script. With some slight adjustments you see that there's nothing more than what we would be typing in right at the Command line.
Let's save what we've written and we'll name it as a script file, so we'll change to this All types we'll name it 06_01.scr for script file. And now we could use Windows Explorer and drag the script file right in or we can use the Manage ribbon, Applications panel, we can Run the script. And notice our new script is selected for us right there in our exercise files, click Open and notice how it zooms extents and sets our new layer Lynda as our current layer.
Color is green, you see how quickly that ran all we did was run commands behind the scenes from an external file and how quickly we were able to set this to zoom extents. We could even write a script and run it from a ribbon or tool pallet just as we would write any other macro or command in macro section as we learned already.
- Using variables and profiles
- Customizing AutoCAD templates with styles and layer properties
- Using dynamic blocks
- Customizing the AutoCAD interface
- Creating custom tool palettes
- Creating and editing scripts
- Adding custom symbols
- CAD programming with LISP