Save Time: Automate with Script File

One of the simple and rarely used feature of AutoCAD is Script. Scripts can be easily created and executed in AutoCAD. It is a type of simple automation and in some projects it can save considerable amount of time.

A script is a plain file, having a sequence of command prompt entries, which gets executed when loaded with Script command of AutoCAD. Script files are similar to batch files but are more flexible. Script files can be easily created using a text editor such as notepad and then need to be saved with .scr extension.

For example, let us create two layers “Road” and “Boundary” with red(1) and Green(3) colour. Just make note of all the entries you make when you are creating layer in AutoCAD. Same thing when typed and saved in Plain text file becomes Script File. If you are executing the same commands many times then instead of executing such commands a script can be used and executed.

Type following text in notepad.

Layer <Enter>
M<Enter>
Road<Enter>
C<Enter>
1<Enter>
<Enter>
<Enter>
Layer<Enter>
M<Enter>
Boundary<Enter>
C<Enter>
3<Enter>
<Enter>
<Enter>

Now save the file as CreateLayer.scr and then in AutoCAD type the command ‘Script’ and load CreateLayer.scr. Now, 2 layers will be created. Please note that in the above shown file <Enter> indicates you give ‘Enter’ Key when creating Script in Notepad.

Some times you will come across requirements in such a way that you need to execute same script file on tens and hundreds of drawing. In such cases ESurvey Lisps can be used, which has in-built script runner. You just need to locate Files or the directory and select the required Script file. ESurvey Lisps will execute the script on multiple drawings at a time.