About this Page: It's a work in progress by a guy who does not know what he is doing: You have been warned. 


  1. Overview
    1. I'm going to start out saying this is very much a novice built page, so know that when you are working with this "resource"

      So here we are embarking on a journey into CAD automation. This particular wing of automation is called macros. Macros are different from Lisp or VBA or Action Macros. Pardon me while i venture a definiation.

      MACRO - In AutoCAD a macro is merely a series of commands.

      In its infancy AutoCAD relied much more heavily on written commands. A natural progression of user friendliness is to to allow for an automation of common command and voila a macro is born. I'm not sure if this is actually how it happened as i was a young lad when this would have happened if it did. Basically macros are a string of keyboard commands that get thrown to the command line together. This is how it is different from a scripting language like lisp of VBA. The scripting languages deal directly with the database information where as a macro is accessing the same information through the same means manual operations of the program does. Action macros are very similar to macros, but they are not composed or managed in the same mannor. 

  2. Parts and Pieces

     Part/Pieces  Dohickey Explanation  Example
    ^C  Clears or cancels an open command. Its an ASCII control character. Typical these start off the macros so as not have issues with left over commands. As macros are just commands they cannot tell what the computer is doing when you start a macro. These are usually double at the start but lately i have seen them tripled so I have been trying to start tripling them so as to make sure my macros are good even if the open command is three prompts deep.   ^C^C^Cline;
    ; Ok this do-hickey or semi colon is the equivalent of hitter the enter key (or return depending on how old the equipment is that you are using). It usually follows the command so as to close out the selection or what ever particular part of the command you are providing options for. It is also a point of voodoo and often i dont understand how to use it properly. For some odd reason doubling it up helps if you are having issues with a macro behaving properly... granted this is terrible advice as its probably something you should be providing proper in input for.  ^C^C^Cline;
    [space] Space is the same as pressing space bar. This is one of the weird ones to. often it acts like a ; but not always. So mostly I've only used it for for p[pressing enter and so i frequently opt to use the ; as it helps visually delineate the macro for me.   
    \ Throw one of these in there when you need to wait for user input. In the example it starts a line a point (0,0) and then waits for user input before completing the command.   ^C^Cline;0,0;\;
    _  Not gonna lie... not 100% sure what this one is used for at the moment.   
    -  This one suppresses the dialog box, or more correctly runs the command only using the command line. So if you have a macro and a dialog box keeps opening but you dont want it to, this is what you will have to use. In this example i used the purge command. if you type in PURGE you will see the dialog, but if you type in -PURGE you will have to look at you command line for input. This example just purges all.   ^C^C-purge;a;*;n;
    P When propted to select an object P can be insterd to indicate Previous. This worsk when you have previously used selection sets.   
    L When propted to select an object L can be insterd to indicate Last. This will select the last object.   ^C^CPOINT;\_.ERASE;L;;

  3. Macro Library
    Macro to Move Object to a Named Layer ^C^C^Cselect;\chprop;p;;LA;LAYERNAME;;

    This macro allows you to select your geometry and then once you have made your selection it will move it to a predetermined layer. This one is useful if you work with templates and known layer names.

    View Res Macro

    ^C^C^Cviewres;n;20000; This initiates the VIEWRES command and sets options N, 20000

    Creates paperspace from template





    This macro automatically grabs a layout called "11X17" from a template file. Insert the path of your template file inside the brackets.

    Note: the slashes in the file path need to be reversed. I.E. C:\AutoCAD\Stuff\Templates\file.dwt would need to look like C:/AutoCAD/Stuff/Templates/file.dwt

    After inserting the template it will enter paperspace 11X17 and zoom extents and switch back to model space

    After that it will delete Layout1 and Layout2

    Macro to Zoom Extents and save drawing and then close drawing


    I use this Macro before I close out drawings. It just makes it clean exit and gets it done in one step.

    Macro to purge reg apps


    Some times there are parts of verticals attached to DWG files. They are things that the verticals use and since I only need the vanilla version of the DWGs I can bring down the file size and prevent any issues from having these reg apps attached.

    Macro to turn off layer ^C^C^C-Layer;off;NAME;; In this Macro it turns off a layer of name NAME. Change NAME to what ever layer you need.
    Macro to turn layer on ^C^C^C-Layer;on;NAME;; In this Macro it turns on a layer of name NAME. Change NAME to what ever layer you need.
    Macro to turn on all layers that start with letter "X" ^C^C^C-Layer;on;X*;; In this Macro it turns on all layers that start with the letter X. the astrick (*) is a wild card. Change X to what ever layer you need.
    Macro to turn off all layers that start with letter "X" ^C^C^C-Layer;off;X*;; In this Macro it turns off all layers that start with the letter X. the astrick (*) is a wild card. Change X to what ever layer you need.
    Macro to zoom extents and activate the layer walk command ^C^C^Czoom;e;laywalk; This macro is whn deciding if its ok to tunr off or freeze a layer. it allows you to zoom out and see what geometry will be affected by looking at the layer in the layer walk.
    Macro to convert poly line and hatches ^C^C^Cconvert;a;a; I get old drawing on occasions that need to update the way the hatches and poly lines are handeled. see the CAD command CONVERT. This does it all in one click.
    Macro to change the color of a layer ^C^C-LAYER;C;WHITE;LAYER1;; This macro will change a layer to a named color. In this example code WHITE is the color that it will be changed to and LAYER1 is the name of the layer that will be changed.
    Macro to change to a specific layer ^C^C^C-layer;set;LAYERNAME;; This Macro will change the current layer to another layer of the name LAYERNAM. So just change LAYERNAME to the name you need when you use it. 
    Macro to change Ribbon Tab to Home ^C^C+RIBBON;ACAD.ID_TabHome This macro will change from what ever tab you are working in to teh home tab. you use the +RIBBON to intializae the change and the ACAD.ID_TabHome (i htink its case seantive) to select the home tab. you could probably use +RIBBON to select other tabs as well though i dont know thier ID off the top.