Wednesday, July 25, 2012

AutoCAD Macros! (and how to kill F1 once and for all)


Ever hit F1 in AutoCAD and opened help when you wanted to hit escape? (Do I even need to ask?!) Ever wish there was a faster way to access your most used commands?

I recently discovered a feature in AutoCAD that greatly increases my efficiency with the program, so I thought I’d share. If you’ve never heard of the CUI, or Customize User Interface command, you’ve been missing out. There is a wide variety of things that you can do within this tool, but the biggest one for me is the Keyboard Shortcuts section.

What does the CUI allow you to do? The chief feature of the CUI is the ability to write your own macros for commands. It also has a way to get rid of the stupid F1 help shortcut. I’ll cover this one first, then get on to the fun part.

How to Kill F1
1 - Type CUI and hit enter. This brings up the Customize User Interface tool.
2 - Expand Keyboard Shortcuts
                -Expand Shortcut Keys. This is where all the magic happens.

3 - Below, in the Command List: search box, type in “cancel”
                -Drag the Cancel command from the search results up into the Shortcut Keys list.

If you want, you can then rename the command to something that reminds you what it is, such as “F1 Cancel Command”
4 - On the right, Underneath the Access property there is a box called “Key(s)”.  Click on it, then click      on “…”  
                -Type in F1. It may ask if you want to override the previous choice for F1 (which would be            “help”) Hit yes if prompted.

5 - Hit Apply.
                -Bask in the glory of never being “Helped” ever again.

Okay, now that F1 is taken care of, let’s move on to the fun stuff. Writing macros is pretty similar to reassigning F1 to use the cancel command, despite being slightly more complicated. The power of macros is in saving time by not having to type through commands that require prompts, such as Extend à all à extend chosen objects… or Rotate à 90 à pick origin à ok

To get started with a multi-step command, such as Extend à all, first type in “extend” in the Command List search bar and drag it into keyboard shortcuts like we did before. This will get a fresh command to alter as we see fit. From there, simply edit to “Macro” line in the Command section of the properties.

 Here’s a list of my favorite macros:

Print Previous: ^C^C-Plot;No;;Previous Plot;;No;No;Yes
                I have this assigned to Shift + Z
                
Extend All: ^C^C_extend;;
                I have this assigned to Shift + R

Trim all: ^C^C_trim;;
                I have this assigned to Shift +T

Rotate 90 Clockwise: _rotate;\90;
                I have this assigned to Shift +4

Rotate 90 Counter Clockwise: _rotate;\-90;
                I have this assigned to Shift + 5

Rotate 180 Degrees: _rotate;\180;
                 I have this assigned to F2

Move Previous: _move;p;;
                Assigned to Shift + M

And then a few that didn’t require any modifications beyond dragging up into Keyboard Shortcuts and assigning a key, but are really helpful:

Clip Viewport: ^C^C_vpclip
                Assigned to Control + Shift + F

Explode: (block or polyline) ^C^C_explode
                Assigned to Shift + E

Measure Area: ^C^C_MEASUREGEOM _area
                Assigned to Shift + A

Move to Paper Space: ^C^C_.PSPACE
                Assigned to Shift + F

Make Current Object’s Layer Current:  ^C^C_Laymcur
                Assigned to Control + Shift + Q

Notes:
-          Notice that the macros begin with “^C” , which is the same as our cancel command? It’s in there twice sometimes to ensure as clean slate for the command that we want to use.
-          “;” in CAD macro language means “enter”
-          “\” means “wait for user input, then continue with the macro”
-          Some macros, especially the “Extend All” and “Trim all” ones took a little bit to overwrite my muscle memory associated with using that command. Stick with it – I promise that it’s faster!

Happy cadding!

No comments:

Post a Comment