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. Im 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;
    *    
    ^    
    $    
    @    


  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

    ^C^C^C-layout;template;

    [YourTemplatePath].dwt;11X17;-layout;

    set;11X17;_.MSPACE;ZOOM;E;-layout;set;

    Model;Layout;d;Layout1;layout;d;Layout2;

    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

    ^C^CZOOM;E;QSAVE;CLOSE;

    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

    ^C^C^C-PURGE;R;;N;

    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.