AutoCAD 2015 and AutoCAD LT 2015 BibleAutoCAD 2015 and AutoCAD LT 2015 Bible

The most comprehensive AutoCAD book around!

Tutorial: Automate tasks with a script file

A 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 Action Recorder, 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 open drawings, 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 open AutoCAD. 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.

Autodesk provides a free program for running script files on multiple drawings, called ScriptPro. The file is called scriptpro.exe.

31 comments to Tutorial: Automate tasks with a script file

  • David Bogenhagen

    Nice tips. I’ve been scripting for a few months, and can’t find a way do a new task. I want to apply a style to existing text in a file. chprop doesn’t get me there and _properties won’t allow scripting commands against it. Anyone have a way in scripting to apply a style to selected text?

  • admin

    I found this by trial-and-error. When I selected some text and chose a new style from the list, I saw _optchprop on the command line. It’s not listed as a command in Help, but I can type it on the command line. Interestingly, I have to type the underscore (which is normally there for purposes of translating AutoCAD). So, I selected some text and tried it. I did everything on the command line. That’s the first step to creating a script, so see if it works for you.

    Command: _optchprop 1 found
    Enter property to change [Textstyle/Dimstyle/tAblestyle/Mlstyle]: t
    Enter text style name: times
    Enter property to change [Textstyle/Dimstyle/tAblestyle/Mlstyle]:

  • James Juarez

    I have been trying to create a script file that will change what I have in my viewport to plot at 50% shading using a ctb file.
    I can not get it to work. I am having to go into my viewport and then select the layers that I want plotted at 50% shading.
    Is this possible to do? If so, can you provide how to get this accomplished?


  • Ellen

    Maybe one of our readers will come up with a solution for you.

  • Shawn

    Hi Elien,
    I’m trying to use script file to stretch the pline and moved ucs to the locations. But it does not working well. Please help and email me back.

  • Cortes


    I go through the steps but I cannot open the .scr file through the script command in AutoCAD 2011. Any suggestions?

  • Ellen

    What happens when you choose the .scr file in the dialog box and click Open?

  • Yakov

    Ellen, can I open files in black and white only using startup.scr?

    Thank you.

  • Tony

    Hi Allen
    I’m trying to find a list of commands I can use in script files, I read somewhere that “if” and other commands are possible.
    I’m trying to right a script to rename layers and set new colors and line types but I’m new to scripts and having trouble making it work.
    Not all drawings will have all layers, so not sure what will happen when the script doesn’t find a layer it’s looking for?

  • Ellen

    Scripts don’t have “if.” If you want “if” :-) you’ll need AutoLISP or another programming language.
    Scripts just execute commands. If you can’t do it by typing on the keyboard, you can’t do it in a script.
    The value of scripts is that you can use them over and over and they can do long lists of commands, even on many drawings.

  • Usman Nazar Rathore

    Hi Ellen,

    Very nice advises, i really appreciate it, my query is similar to this blog, i have a file in my c drive, location is C:\Documents and Settings\urathore\Desktop\INNOVATION\TEST_120503_001.test110147160113_003.dwg, meanwhile my script is saved with the same folder with USMAN120507.scr.

    My confusion is that in that case what i am doing is that i am creating shortcut of test110147160113_003.dwg and then in TARGET option of the shortcut i am writing ahead of the path (as advised above) /b USMAN120507.scr (even tried without .scr as well), the test file opens but the script does not run, i have successfully run the script within the test file many times, perhaps i am doing it all wrong.

    Will really appreciate your gracious guidance !

  • Andrew


    I created a block with an attribute within a drawing, and wrote a script to insert instances of that block at various points and define its attribute. A typical line in the script would read: Insert BlockName ###,### 1 0 Attribute, with the 1 and 0 being for block scale and rotation respectively.

    The first time I run my script in the drawing, it places the blocks and defines their attributes fine. If I try to run it again, it will place the blocks at incorrect coordinates but still get the attribute right. The incorrect coordinates are nowhere in the script. I am somewhat confused as to what is happening, and I would appreciate it if you could give me some tips.

    Thank you.

  • Binod Maharjan

    i have problem in printing a lot of document at a time. i’ld like to know if there is any idea to automate printing command using windows command in autocad.

  • I teach high school cad / drafting. I have always had my students create short little “slide show” animations using slides created with mslide. In 2013
    non of my script files run, and I can not get any slide show created in 2013 to show any of the slides. What could I be doing wrong?
    Example of script file:
    vlisde slide001 delay 1000
    vslide slide002 delay 1000
    The slides are located in the same folder where the current drawing is saved.
    I have filedia set to 0.


  • @ Usman
    Dear Usman you can not run a script file automatically on opening you have to run it manually using “SCRIPT” command inside AutoCAD.
    The method Ellen suggested is to run a script while opening AutoCAD. This way you can customize the way AutoCAD presents itself on opening.

    Please correct me if I am wrong.

  • @ Andrew,
    Hi could you please send the script file. so that I can review the same and find out the flaw. Send it to thecadders @

  • Ellen

    I think you’re right.

  • Fernando

    I want replace o redefine a block.
    I did a script file to reinsert my block but insert the same block is inside my drawing insted the file from my hard drive.
    this is my script file:
    _.OPEN “C:\Dropbox\Fixtures Glendale\Ernestomeda\Kitchen 02\Dwg\Kitchen 02 Elev.dwg”
    filedia 1
    insert “c:\dropbox\borders\Presentation 11×17.dwg”
    erase l

    this script file works but don’t redefined my old block.
    thanks for your help.

  • Claude Carlson

    Excellent topic.
    Scripts are the reason I wrote EZScript-Pro.
    And it has made my CAD life easier.
    Good luck.


  • Misha

    Where I can find a kind of list of options for scripts commands? I need to use a commande “text”, but I dont know the ordre of its options, such as coordonates, justify etc.
    Thank you!

  • Ellen

    Either look in Help or just try out the command using the keyboard only. Then write down each keystroke — that’s usually what I do.

  • Cadder is incorrect.
    You most certainly can open a script automatically when starting AutoCAD. From the DOS command Line you call ACAD.exe and the name of the script to be opened.
    This is the basis of EZScript-Pro.

  • Yes, you can start AutoCAD and specify a script. You use the /b command-line switch. So, if your script file is setup, you would do something like this:
    acad.exe “c:\drawings\my drawing.dwg” /b setup

    I write about command-line switches in the Appendix on installing and configuring AutoCAD of my AutoCAD Bible.
    You can even create a script that does this for multiple drawings but EZScriptPro and Hurricane automate the process for you.

  • Todd S


    I am using a .scr file to plot many 3D objects. But when they are plotted the coordinates do not match the coordinates of the script file. I check the command history and it matches the script file. Futhermore, when I start over and re-run the script it plots something new every time.

    I am plotting spheres using the following as an example of the script


    Any suggestions?

  • Rob

    Problems with coordinates usually come from object snap.

  • Jojo Maple

    I am trying to create a script to insert a stamp block to a drawing and save:

    open “C:\TEMP\1374\MCF-2-611-AA-0008-01.dwg”
    _insert “C:\TEMP\1374 M_CJB_PERMIT-STAMP_dated” 227.26,18.19 saveas “C:\TEMP\1374\Stamped folder MCF-2-611-AA-0008-01.dwg” zoom e Qsave

    Somehow it is able to open the drawing and stops and displays an error message.

    I am new to this.
    Any advise is highly appreciated.


  • chetan

    hello Ellen,
    can I use amscarea command with script?

  • himanshu limbachiya

    dear madam,
    i made one command in lips.that i loaded in command require other 14 inputs for complete drawing.

    now i made one scr. file for it.but problem is its work for only 1 time
    just a example : _non 0,0,0 5 _non 0,0,0 50 _non 0,0,0 100

    than autocad draw 3 circles of 5 50 & 100 dia

    but i write :
    _.bcs _non 0,-20000 C PB1 10000 350 400 400 400 Y 4 4-D12+2-D16 4-D12 4 4-D20 2 8 150 0 2 +0.000
    _.bcs _non 10000,-20000 C PB2 10000 350 400 400 400 Y 4 4-D12+2-D16 4-D12 4 4-D20 2 8 150 0 2 +0.000

    than autocad draw only for 1st time use of command and than show error that _.bcs command not found.
    but if i type “bcs” in command line command works

    my question is why these things happen and wt i do to run my command so many times that i want with help of .SCR file

  • Imran

    HI Admin,
    I want to Import Manhole OR point text in Autocad using SCR.
    Kindly Guilde me whole Procedure,
    Imran Faiz Butt

  • SteveH

    I am trying to write a script in Autocad 2012 to change attributes in a drawing title block, with limited success. see script below;

    ; ————————————————————
    ; ————————————————————
    ; ————————————————————

    ; ————————————————————
    The above works perfectly, BUT…I would now like to modify the script to use a wildcard for the ‘Enter string to change’ line. This wildcard is to enable the change of ANY existing string to the replacement string.

    I have tried using *(asterix), but that doesn’t appear to work for full strings.

    Any advice would be greatly appreciated.

    NB. I’m trying to keep this really simple and script based only. So please, no LISP routines.


Leave a Reply




You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>