AutoCAD Tips: Macros

Ralph Grabowski of UpFront eZine and the new blog WorldCADAccess wrote a nice answer to a readers question on what a macro is. I also added some very helpful tutorial links to the bottom of this posting.

“Q: Would you please tell me what macros are please?
– student.ul.ie

A: A macro is anything more than a single command. For example, in AutoCAD you zoom into a windowed area with the ZOOM command, followed by the W option. When you assign that to a menu item or a toolbar button, “zoom w” is called a macro.

A macro can consist of just a command and an option, as shown above, or consist of many commands, their options, and other programming code (AutoCAD macros can include Diesel expressions and AutoLISP functions).

Macros often include additional code to make sure it works under all conditions. For example, “^C^C^C” is added as a prefix to cancel any AutoCAD command still running, while the _ (underscore) is added to ensure the macro works with any language version of AutoCAD (German, Japanese, and so on).

Programs other than AutoCAD don’t necessarily allow macros; instead, they have their own programming interfaces, or might require you to learn VBA (Visual Basic for Applications) to write the equivalent of macros.” http://worldcadaccess.typepad.com/blog/2004/02/tips_macros.html

Helpful resources on macros for AutoCAD:

  • AutoCAD – Example of using macros to automate your work: Faster block insertions

  • Applying Customization: Building More Complicated Macros

  • AutoCAD – Applying Customization: A LISP Macro Zoom

  • Applying Customization: Macros For Toggling Between Large and Small Cursors

  • Applying Customization: Writing LISP Macros Plus a Bonus 3D Toolchest

  • AutoCAD – Lock Viewports Toolbar Button Macro

  • Applying Customization: Building a Toolbar

    Cheers,
    -Shaan

  • 14 comments

    cb says:

    can i find out where and what the macro scrips are for
    autocad. i have loaded extended LT facilities and am
    trying to isolate layers by pick , just like the layiso
    command in full autocad express. can anyone help please.
    cb

    claude says:

    HI,
    Could you help me with Autocad ?
    How could I make a macro which would create and display a new sheet and put a new number automatically incremented as an information, this after a click on an object (circle, line etc.)
    I hope i’m clear, sorry for my english, I’m french and I studied english by myself
    Thanks a lot for your help
    Claude

    Robert (Bob) H. Englert, Jr. says:

    To Whom it may concern,
    Hi. I just got AutoCad 2008. I want to know how to make a toolbar that will draw a line and the layer that relates to it so all I have to do is toggle the toolbar button to get the line, color and line type all in one. I know this can be done because I used to set up Fastcad to do it and if it can be done in DOS, I know it can be done in AutoCad. My E-Mail address is bob1@alltel.net. Thank you for your time and efforts in this matter.
    In God’s loving service,
    Bob

    Bob,
    All you need to do is use your tool palette and then on the line command icon right-click and set the propereties you would like that line to be drawn such as scale, layer etc. You can create multiple line comands on the tool palette for different properties or specs.
    Regards,
    Shaan

    sachin sharma says:

    hay dear,
    could you please tell me first step for create the macros.
    means i know the auto cad but i want to make a macro, it’s related with create new line type/shape.
    Regards,
    sachin

    Jon says:

    I need help writing a macros for a button that will open the design center in autocad ’04 to a folder in my “My Documents” folder on my computer.
    Thanks,
    Jon

    Jon,
    AutoCAD has come a long way since 2000 and now most use Tool Palettes as it allows you to silently enforce standards as well and more power. I am not sure many even realize the good power of Design Center beyond inserting blocks.
    I am not sure you can do with a macro exactly what you want as there is not a keyboard method to set the folder in order to create the macro. In order to set the folder you need to open the ADC and then select the folder tab and then select a folder to set as home in the right-click menu. You could just set it once unless you are asking for multiple profiles then just call ADC in your MNU file.
    I hope that gets you started. There is an excellent customization resource and that is the Autodesk AutoCAD customization discussion forum and the AUGI forums and the experts of customization hang out to help in there.
    http://discussions.autodesk.com
    http://www.augi.com
    Shaan

    Michael says:

    Hi
    I have taught myself a few minor things about Macros and can create small macros but i was wondering if you could answer a few questions about them
    One thing is that i can make a macro to save a DWG as a certain name like ”temp.dwg” but i am trying to find out how to do somthing like make it more dynamic ie. if i open a drawing called temp.dwg i would like it to make it save as the existing name and then ”REV1” as a suffix
    But then be able to open another drawing ”tempxyz.dwg” and then, using the same macro, save it as ”tempxyzREV1.dwg”
    Any help on this subject would be really helpfull as i am just starting to understand macro’s
    thanks
    Mike

    Hello,
    I am looking for some assistance in creating a macro for autocad lt 2005. all i really want to do is create a marco that will allow me to press a button, and plot the file with the previous plots settings. if you have any insight into this please contact me at the email listed.
    – Jeremy

    GR says:

    I want to have a button that will cause a circle after using the “normal” circle button to imediatly scale its self to a set number. Reason is i do a lot of emperial modleing and many parts are metric so if i want to make a circle-input its dia. in mm and have it scale correctly in inch space?

    GR,
    This is more than a script IMHO. I would suggest asking in places like Autodesk AutoCAD Customization forums (http://discussion.autodesk.com) or AUGI.com for pointers on developing a LISP file instead of a script.
    Best Regards,
    Shaan

    Brad says:

    I’m wondering how to create a macro that would do the following;
    -create a circle
    -measure the circle’s diameter or radius
    -then create a text with the measurement
    I think learning this would also assist me in creating many macros with this similar procedure.
    Thanks

    V.Chandrasekhar says:

    Hi,
    I would like to ask about Auto CAd Coordinates.
    How can i paste from an Excel sheet entered coordinates to Autocad. Please suggest me.
    V.Chandrasekhar

    Leave a Reply to Robert (Bob) H. Englert, Jr.Cancel reply