Category: AutoCAD Tricks

My Favorite AutoCAD Macros

As promised, here are a few of my macros that I use on a daily basis. Steal these ones, or devise your own for yourself!

  • Horizontal Construction Line:  ^C^C_XLINE;H;

Creates a horizontal extension line at infinite length for construction.

  • Vertical Construction Line: ^C^C_XLINE;V;

Creates a vertical extension line at infinite length for construction.

  • Create Polyline: ^C^C_PE;\;J;

Enters polyline edit command and automatically enters the join option.

  • Lock Viewports: ^C^C_-VPORTS;LOCK;ON;ALL;;

Locks all viewports on the current layout tab.

  • Un-Lock Viewports:  ^C^C_-VPORTS;LOCK;OFF;ALL;;

Un-locks all viewports on the current layout tab.

I use a layer called “Construction” where I make a lot of chicken scratch, notes and model space dimensions. Usually when I’m done I like to freeze this layer; or when I need this layer on and off quickly for visualization, this is the button I use:

  • Freeze Constructions: ^C^C_-LAYER;SET;0;FREEZE;CONSTRUCTION;;

Freezes the construction layer and sets the current layer as “0”.

  • Thaw Constructions: ^C^C_-LAYER;SET;0;THAW;CONSTRUCTION;;

Thaws the construction layer and sets the current layer as “0”.

I continually need to insert blocks from a common network directory throughout my day. The following button lets me simply type the name of the block into the command line and it will insert. If you are to make a button like this, you will need to add the folder directory in which the block comes from to your “Support File Search Path” and “Working Support File Search Path”. To do this, follow these instructions:

  1. Click “File” then “Options” or simply type options into the command line.
  2. Click the “Files” tab and click the small + sign next to the top two items so your window looks like this:

  1. Click on the text of “Support File Search Path” so that it is highlighted and click the ”Add…” button on the right.
  2. Now, you will need to browse to the folder of your intended block directory.
  3. Click on the text of “Working File Search Path” and follow the same process.
  4. Click Apply and Close.

My code reflects a “B” that automatically enters due to the fact that the name of every block in this directory starts with “B”. I don’t want to have to type it every time.

  • Insert Shape: ^C^C_-INSERT;B\;\;1;1;0;

Definitions of symbols:

; – I defined the semi-colon in the last post as being equivalent to hitting enter or the space bar.

– – A dash was also defined in the last post as the indicator that prevents a window from appearing for a command that would normally launch one.

\ – backslash is a new one. This is a “pause for user input” signifier. In my last example, you see two of them used. The first is to let me type in my extrusion number (block name), and the second lets me place it where I need to on screen with a click.

Some of the examples here, as you can probably tell, are pretty specialized. This is how you should be using this method! My examples are to simply show you how the tool works, now you need to think about what your daily time wasters are and create something that can help you through it.

I also wanted to note that when making an image for your button you can browse to an image that you have downloaded or pulled from somewhere else.  I know that I am not an artist and have trouble concocting a suitable image that will convey the intent of the command activated by the button, so this is what I do!

 

Anger clouds the mind. – Master Splinter

…. and your AutoCAD drawings.

Enjoy the day.

You’re Typing Way Too Much… Use Macros! (Creating Custom Toolbars & Buttons)

This one is a twofer. First will be a quick lesson on creating a custom toolbar with buttons along with a shnazy image (so you remember what it does), as well as a “how to” on creating a macro to save steps whilst going through your commands.

I sit next a very loud typist. He’s a designer and uses AutoCAD daily. Some days (most days) it sounds like he is working on his next best selling novel that will hit bookstore shelves in two weeks and he’s struggling to meet his publisher’s deadline. He’s really just using AutoCAD, and killing his keyboard in the process. Save your keyboard! Save your mouse! Save your neighbors, for goodness sake! Exaggeration intended…

Many commands have a lengthy string of additional options inside the initial command which must either be typed into the command line, or clicked through in menus. A lot of times you’re repeating the commands you use throughout the day and many of these commands are multi-entry commands. Case and point – Fillet. Most of us don’t just fillet one item at a time. So, we enter the fillet command, then type the command for MULTIPLE. (It’s a different key in different releases. From here on, I will be using “M” for multiple in this example.) This is really an extra step in your day and a button could be created for this operation. The macro you would assign to your “Fillet Multiple” button would be ^C^C_FILLET;M;. This is a very simple and minor example and I’ll dissect this code later on in the post, but the operation would be one click of a button from now on.

Just to simplify my statement above and give it a definition; A macro is the equivalent of typing commands into the command line, Which, coincidentally, is the best way to preliminarily construct and troubleshoot your custom macros.

First, we’ll create a new toolbar. (Please note that this method will be for releases of AutoCAD 2006 and later using the .cui file.)

  1. Simply type “CUI” into the command line. It should look like this:

  1. In the top left pane (Customizations in All CUI Files), click the plus sign to expand “Toolbars”.
  2. Right Click on the text that says “Toolbars” and then click “New Toolbar”. Congrats. You have just created your very own toolbar.
  3. In the right pane (Properties), you will see all of the data about your new toolbar. Click in the “Name” section under “General” and call it what you will. You can also add a description here if you like, but most of the other properties I don’t typically mess with.

Next we’ll create the custom button.

  1. From the CUI window, Check out the bottom left pane (Command List).
  2. Click the button that looks like a shiny star. (The “star” button on the right.) If you hover over this one, it will say “Create a new command”. This is what we want to do.
  3. “Command1” has now appeared in the “Command List” area and your “Properties” on the right have changed as well. We’re going to start simple and create the Fillet Multiple command.
  4. Click in the name section and type “Fillet Multiple”.
  5. Click in the description section and type “Enters Fillet Command for Multiple Instances” You can make this whatever you want. It’s just to remind you of what the command is if you have a large amount of custom buttons.
  6. Lastly, click in the macro section. After the ^C^C, add: _FILLET;M; So the entire macro should read: ^C^C_FILLET;M;
  7. In the top right pane (Button Image), scroll through the images to find the image for Fillet and click on it.
  8. Next, click the edit button and scribe an “M” in the empty space using the line or pencil tool. This will differentiate your modified fillet from the standard fillet. Click “Save” when you’re done.
  9. Click “Apply” at the bottom of the window. Then click “OK”.

If your new toolbar is not floating in space, right click on any button you like and find your toolbar in the list. Click it and now it will be floating in front of your face and you can drag it and dock it wherever you like. Be sure that each time you add a new toolbar or modify an existing toolbar, afterwards export your template. This will update it with your current interface.

Here is what some of the general functions of the macros are:

“-“ – A dash before any command will eliminate a window opening. You can then navigate using text commands instead of click. This is the way to make macros for certain commands. For example, PURGE or XREF.

“;” – Semicolon is the equivalent of hitting enter or the spacebar.

“^C” – Carrot and “C” is “CANCEL”, or the equivalent of hitting Escape. It’s a good idea to place this at the beginning of all macros just to clear the command line.

Remind me to outline the process of exporting your toolbars in case you’re re-formatting or something similar where AutoCAD gets uninstalled. It’s a little lengthy and not really applicable quite yet.

Have fun with these, experiment and don’t hesitate to leave feedback or ask questions in the comment thread below. I will respond! My next post will be a list of my favorite, time saving macros that I use on a daily basis and one’s I have created in an effort to reduce my department’s redundant tasks.

Anger clouds the mind.

…. and your AutoCAD drawings.

Enjoy the day.

A Heap of Random Tricks

Here are just a few items with no real category. These assume some AutoCAD know how. FYI.

Rotate / Scale Using “Reference”

This is something I’ve taught to countless colleagues. I’ve worked in many different facets of the design industry and one thing never fails. Things get knocked out of scale and who wants to figure out a scale factor to get it back to the correct scale? No one… use a reference! For example, if you have an object that should be 1” tall (or part of the object should be 1 inch tall or wide).

  1. Type “SCALE” into the command line, and select a base point.
  2. Next it will ask for a scale factor or reference. At this point, type “R” (For “Reference”).
  3. Click one end of the object that you know to be 1”, and then click the other end of the object.
  4. Now it asks you to specify a new length, or use the distance between two specified points.
  5. For this example, type 1. The reason you would need to click two points would be that the object needs to be a strange dimension that is not an even number or you have another object on screen at that same size to reference.
  6. You’re done! With no scale factors in sight.

Rotate works in a similar fashion. If you understand the example above, rotate will be a piece of cake.

DVIEW – Rotating Views Inside of Viewports

This is a great trick when you need to turn a part sideways after you have already drawn it and you’re working out how your layout is going to look. DVIEW is the command for you.

  1. Double click inside of your viewport and type DVIEW.
  2. It will ask you to Select objects or use DVIEWBLOCK; This is what we’re going to use, so just hit enter again.
  3. Next type TW and enter to opt to use the twist method.
  4. Now it will ask you to specify a twist angle. I usually use 90°, so simply type 90 and enter.
  5. We’re now back at the top menu, so just enter again to leave the command.
  6. The viewport will regenerate and you’ll notice that everything inside your viewport is now rotated at 90°.

Quick Block Creation

A real easy way to create a block on the fly is copying the items you want to be contained inside of your block and pasting by usingCTRL+SHIFT+V, or by going to “Edit” then clicking “Paste as Block”. The downside of this method is that it’s name will be randomly generated and, unless you copied with a base point, it will most likely not be where you need it as well. But, for quick grouping of objects and a method for creating “throw away” blocks that will be only temporarily used, it’s quick and easy.

 

Anger clouds the mind.

…. and your AutoCAD drawings.

Enjoy the day.