How do you create an AutoCAD script?

Can I create an AutoCAD script?

Asked on September 27, 2016 in AutoCAD.

Hi, 1. Create an ASCII text script file called model_ext.scr. 2 . Add the following AutoCAD commands and AutoLISP functions: … 3   Test the script for proper operation. … 4   Click Project tab Project Tools panel Utilities. … 5   Select the Run command script file option. 6   Browse to the script file. 7   Click OK.

on November 20, 2019.
Add Comment
2 Answer(s)


AutoCAD commands that you would normally 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 1

Open NotePad.

Step 2

Copy the following code to your NotePad

(Note! Comments can also be included in the script file.The lines that contains the ‘;’ sign are interpreted as comments):


;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!
Right ;The last view is named ‘Right’

Step 3

Save using the extension .scr

Step 4

Type ‘scr’ at the command line if you want to run a script!



The Previous Procedure Can be seen done in the following Video:

RE: How do you create an AutoCAD script?


A Full List of Commands can be found at:

Answered on September 29, 2016.
Add Comment

script is a macro, a list of commands that you can run all at once, and as many times as necessary, allowing you to automate tasks that would take a long time if you did them manually. Scripts can be very powerful and you can run them on objects in one drawing, or on many drawings. Scripts have been around for many years and many people have a library of many scripts that they use.

See my tip, Record Actions with the Actir,on Recorde for a way to record your actions in AutoCAD 2009 and later.

Here are 3 important points that you need to know about scripts:

  1. Scripts are text-only (ASCII) files. You usually create them in Notepad.
  2. They have an SCR filename extension, so be sure to save them that way.
  3. Scripts use command-line syntax only. They can’t access dialog boxes, toolbar buttons, etc.

Follow these steps to create a script file:

  1. Set the FILEDIA system variable to 0, to stop dialog boxes that access files from opening.
  2. Run through the steps that you want to automate, using the command line only. Write down (or type in Notepad) the steps. You can copy your command line entry directly to Notepad. Press F2 to open the AutoCAD Text Window for that purpose.
  3. Press Enter at the end of each command or use a blank space, which is the equivalent of pressing Enter. The script reads every space, so you need to get it exactly right! The script is easier to read if you put each command on its own line.
  4. Enclose layer names or files names (and file paths) that contain spaces in quotation marks.
  5. Insert comments periodically for explanation. To insert a comment, precede the text with a semicolon.
  6. Save the file with an SCR filename extension, by typing .scr after the file name.
  7. Set FILEDIA back to 1.

To run and test the script file from within a drawing, use the SCRIPT command. A dialog box opens, where you can choose your script file. Click Open and the script runs.

Let’s say that you want to run a script file on more than one drawing. You can use the OPEN, CLOSE, and QSAVE commands to opendrawings, run some commands, save the drawings, and then close them. You can still start the script from within the 1st drawing, but you can also start a script file as you open AutoCAD.

To do so, you change the expression that Windows uses to openAutoCAD. The best way to do this is to use the shortcut on your Desktop. Follow these steps:

    1. Right-click the shortcut and choose Properties.
    2. Click the Shortcut tab.
    3. At the end of the existing expression (which reads something like C:\Program Files\AutoCAD 2009\acad.exe) add a space and then the following:

/b script_name

  1. Click OK.
  2. Double-click the shortcut to open AutoCAD and run the script.
Answered on November 10, 2017.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.