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:
- Click “File” then “Options” or simply type options into the command line.
- Click the “Files” tab and click the small + sign next to the top two items so your window looks like this:
- Click on the text of “Support File Search Path” so that it is highlighted and click the ”Add…” button on the right.
- Now, you will need to browse to the folder of your intended block directory.
- Click on the text of “Working File Search Path” and follow the same process.
- 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.
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.)
- Simply type “CUI” into the command line. It should look like this:
- In the top left pane (Customizations in All CUI Files), click the plus sign to expand “Toolbars”.
- Right Click on the text that says “Toolbars” and then click “New Toolbar”. Congrats. You have just created your very own toolbar.
- 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.
- From the CUI window, Check out the bottom left pane (Command List).
- 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.
- “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.
- Click in the name section and type “Fillet Multiple”.
- 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.
- Lastly, click in the macro section. After the ^C^C, add: _FILLET;M; So the entire macro should read: ^C^C_FILLET;M;
- In the top right pane (Button Image), scroll through the images to find the image for Fillet and click on it.
- 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.
- 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.