Script Files can save Time while working on CAD Drawings
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 a considerable amount of time.
A script is a plain file, having a sequence of command prompt entries, which gets executed when loaded with the 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 layers 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.
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.
Classic Example of script File is purging all the drawings in one directory. When there are multiple drawings in a project over a period of time, drawing may have unwanted layers, blocks and because of that drawing files may be big in terms of file size and when such drawings are opened for editing it may be working slowly. Using purge command all the unused objects from drawing can be removed and this whole process can be automated with Purge Script and Batch Run Script utility.
Purge Script Content. Copy and Paste Following Script in a File and save the file with Extension ‘SCR’
; PURGE ALL UNUSED
<Leave a Blank line by giving Enter>
Sometimes you will come across requirements in such a way that you need to execute same script file on tens and hundreds of drawings. In such cases, CADBatch Runner can be used, which has inbuilt script & lisp runner. You just need to locate drawing Files and select the required Script and lisp file. CAD Batch Runner will execute the script on multiple drawings at a time.
How to Run Script and Lisp on Multiple Drawing
Open Batch Run Script utility
1. First we have to select the drawing files on which we have to run script and lisps
2. Select Drawing Directory to select the drawing file. If you click on ‘Include Sub Directory’ options even the drawings from Sub directories will be selected
3. If you want to select drawings from multiple locations click on ‘Select File’ Option and selected required files only
4. All the selected files will be listed in ‘Drawings’ Group. Un select the drawings on which you don’t want to run the Script or lisp
You have to select script and Lisp from ‘Select Automation Component’ Group
5. Select Script with ‘…’ button next to respective Items and Click on Add" open="no"]
6. When you select Lisp, you have to provide the command name that has to be executed also. Once drawings are selected and required scripts and lisps are selected
7. Click on ‘Run Script’ Button – Utility will open each of the drawings in the list and run Scripts and Lisps on each one of the drawings" open="no"]
8. Alternatively you can click on ‘Create Script’ button and generate the complete script as a Script File, which can be executed later in your CAD Package with Script Command
Click the Link below to Download: