AutoCAD 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. Using Scripts in Autocad can be very powerful and you can run them on objects in one drawing, or on many drawings. AutoCad Script function 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 script in AutoCad:

  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.

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.

If you require more automation beyond the functionality of Script in AutoCad , you may need AutoCad AutoLiSP function or other programming language. Check out our blog post comprehensive AutoLisp tutorial on How to create  a custom command for AutoCad using AutoLISP.

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
    4. Click OK.
    5. 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.

For those interested to explore Automation in AutoCad further, you will find more comprehensive AutoCad Lisp commands, AutoLISP tutorials & examples in my book, Top Customization Tips Every AutoCad Users Should Know.

Ellen Finkelstein

48 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.


  • The Cadder

    @ 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.

  • The Cadder

    @ 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.


  • Alex

    Hi Ellen!
    I try this
    to get a gear of two SQUARE tooth wheels. I have downloaded and installed ACAD especially for the project. For now I could run this script to get a result curve (made out from big white wheel on the left) for primitives I draw in small red circle on the right. Everything seemes to be okay but when I try to paste there (to the right red circle) ready made (complicated) pattern from another CAD software the script goes ERROR. Where my mistake is? Please answer in a most common words in order to let me know you’re interested in further conversation. Then I put more specific questions.

  • Don

    I am doing a conversion of dgn to dwg and one of the task that i need to do on each files is to set-up the layout. Here is the steps I am doing for of 5000 files.
    Page setup manager
    plotter name to DWG To PDF.pc3
    paper size ANSI E(34.00×44.00 Inches)
    What to plot Window (then i will select the corners of the border)
    Center the plot
    then OK.
    Hope you could assist me with this as i will be doing this to at least 5000 files. I already completed 3000+ files manually.
    Hoping for your reply.

  • Behrouz

    Hi Ellen,
    Thank you for the great tips. I got the AutoCad Bible from my university ebook library, but unfortunately I couldn’t find the CD contents.
    My main question is about automatic design in CAD. It is actually a part of my research at university to automate 3D modelling. May I ask you to recommend a programming language for that. I know there are AutoLISP and VBA for CAD, but I’m not sure which one to use and I’m not sure how ‘Scripting’ is different from these two.
    Thank you so much in advance for your great help.
    Best Regards,

  • Behrouz,
    I’m not an expert in programming, but you can actually use any language that .NET supports, as far as I understand.

  • Behrouz

    Dear Ellen,
    Thank you so much for getting back to me and your kind reply.
    May I ask if it is possible to automate some actions like changing block attributes or anything else that is normally done in a separate window through using Scripts.Because it does not show any track of actions on command line or when I press F2 to see what really happened, but I’m not sure what has happened behind the scene.
    Thank you so much in advance.

  • Darren

    Hi Ellen,
    I’m new in the exploration of automated drawing and I chanced upon your informative article. Good work! As a newbie, I’m wondering if it’s possible to write an algorithm, for example, for autocad to scan an existing drawing for a square and then draw a circle in it. Is this wishful thinking?

  • sathishkumar

    I wanna know about car moving script, plz tell me any one.

  • Jeff

    how do I lock an endpoint to another line so that it’s angular relationship can change when the length of the endpoint line changes? The endpoint is locked to the line but would allow it to slide along the other line as the endpoint line grows or shrinks. No under or overshoot is allowed (no trim or extend). I would like to use an excel file for the ‘lengths’, so that as they change; the drawing changes.

  • Thank you, Ellen. I’m work in the same way. Automate tasks and execute custom AutoCAD commands, functions or scripts over multiple folders loaded in runtime such as ARX, ObjectARX, LSP, VLX, DVB and FAS without open AutoCAD using Autocad core console.


    HI ALL





  • Erika

    I have been working on updating some automatic filed variables within a block, and have found that my FIELDEVAL has been set to 0. is there a way to set this to 31 for everything? I thought that a script would be the best way, but I do not want to have to run a script every time I access a drawing.


  • Clart

    I only had position problems on 2 occasions. The first was that one or other snaps were left on. The other, was that the company had given me a cracked version of autoCAD on the machine they assigned to me. When I ran the exact same script on a legitimate copy I had no random positions.

  • Thang

    I’d like to have a script merge layer “G-ANNO-NPLT” to “Defpoints”, for multiple dwgs at one, I don’t know how to write script file, I’m just cad drafter, will be big help for me, many thanks

  • Nijil

    Hi ellen,

    I want to run _ update title block.lsp using script… this loads but need to specify .csv file then only it will update the drawing..
    Question is what would be the command in script to open this csv …please help

  • Glen McCarley

    Hi Ellen,

    I am wanting to open a specified drawing and then save that drawing to another directory and keep this saved drawing open to work on it.

    I have used in a script file the following:

    _open “G:\BI\CD\CD_Business\Engineering\Ground\CAD\CPOHoriz-A3-GE-BH.dwg”

    Unfortunately it is only allowing me to type in the new directory and not giving me a dialogue box so that I can navigate to where I want to save the drawing.

    Can you please help or direct me to an area for an answer?


  • Keith

    It’s been over a year since last post but hoping you can help me with the following script file for a slide show. I’m new to scripting so trying what I thought was a simple script. I can get it to run partially so went from 4 slides to 2 to narrow problem down and changed delays. Locks on slide 1 display but *.scr still running.I’m running win 7 64 with acad 10.

    ;show slide 1
    vslide d:\acaddrawings\dylangears1.sld
    ;delay 2 seconds
    delay 4000
    ;show slide 2
    vslide d:\acaddrawings\dylangears2.sld
    ;delay 1 second
    delay 2000
    ;return to top of script

    Thank you for any help.

  • nice tips i will try thanks cad

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=""> <s> <strike> <strong>