How to create a script in AutoCAD?
If you want to automate repetitive tasks, then you should use scripts.
Scripts are instructions executed by computer which could alternatively be executed one by one, by a human operator.
-
Step 1:
Creating a script is actually a simple action which imply to create a set of instructions that are exceuted automatically by a script interpreter.
These instructions can be executed within any text editor, such as Notepad. -
Step 2:
AutoCAD commands that normally you would execute one by one are written in the text file as lines.
Let’s make a simple script that creates automatically three UCS’s: Front, Top and Right. -
Step 3:
Note!
Comments can also be included in the script file.The lines that contains the ‘;’ sign are interpreted as comments. -
Step 4:
Just type into Notepad these sets of instructions or copy&paste them from this webpage.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;This is a comment. ;
;Comments will not be interpreted by application. ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
_-view ;This it’s the first command that will be interpreted
Front ;Set the view to Front
UCS ;Starts the User Coordinate System command
na ;NAmed option
s ;Save the UCS…
Front ;… with the name ‘Front’
_-view ;Starts the view command…
Top ;…and sets the view to Top
UCS ;Same steps as above!
na
s
Top
_-view
Right
UCS
na
s
Right ;The last view is named ‘Right’ -
Step 5:
Note!
Don’t forget to save the file with the .scr extension!
Type 'scr' at the command line if you want to run a script!