Start learning with our library of video tutorials taught by experts. Get started

AutoCAD: Tips, Tricks, and Industry Secrets

Creating macro-enabled tools


From:

AutoCAD: Tips, Tricks, and Industry Secrets

with Jeff Bartels

Video: Creating macro-enabled tools

One place where you can save yourself some clicks is by creating a macro-enabled tool. Macros automate the way a command works, entering your favorite options automatically. In this lesson we're going to learn how to create a macro-enabled tool. On my screen I have a drawing of a plat of survey and I would like to purge this drawing and remove all of the unnecessary information. Let's see how many steps that is. First, I'll open the Application menu, then I'll come down to Drawing Utilities, and I'll select Purge.
Expand all | Collapse all
  1. 1m 28s
    1. Welcome
      53s
    2. Using the exercise files
      35s
  2. 47m 11s
    1. Adding relevant data to Quick Properties and tooltips
      5m 38s
    2. Creating custom ribbon tabs and panels
      8m 55s
    3. Creating macro-enabled tools
      10m 29s
    4. Increasing speed with command aliases
      4m 44s
    5. Finding commands and system variables using Auto Complete
      2m 35s
    6. Optimizing the size of palettes
      3m 17s
    7. Accessing drawings using Favorites
      2m 25s
    8. Controlling notification bubbles
      2m 24s
    9. Restoring hidden messages
      3m 53s
    10. Following a blog from within AutoCAD
      2m 51s
  3. 1h 0m
    1. Disabling mode settings on the fly
      3m 28s
    2. Finding hatch boundaries in busy drawings
      3m 32s
    3. Generating boundaries from difficult shapes
      2m 20s
    4. Calculating the overall length of multiple entities
      6m 16s
    5. Calculating the area of multiple shapes
      4m 42s
    6. Flattening geometry to a single elevation
      4m 0s
    7. Trimming all entities to one side of an object
      2m 42s
    8. Eliminating duplicated geometry
      5m 10s
    9. Creating true offsets
      3m 44s
    10. Finding errors when joining multiple entities
      6m 48s
    11. Moving and copying entities using Windows shortcuts
      2m 24s
    12. Solving expressions using the command prompt calculator
      5m 1s
    13. Using the Calculator palette
      10m 25s
  4. 21m 17s
    1. Bringing all text objects to the front
      1m 20s
    2. Underlining single-line text
      1m 21s
    3. Managing numbered and lettered lists
      3m 36s
    4. Creating superscript and subscript text
      3m 18s
    5. Removing formatting from MTEXT
      3m 26s
    6. Using fields to identify who revised a drawing
      3m 10s
    7. Squeezing text into tight spaces
      3m 5s
    8. Hiding extra annotative scales
      2m 1s
  5. 16m 55s
    1. Creating "one-click" dimensions
      1m 52s
    2. Dimensioning angles greater than 180 degrees
      1m 40s
    3. Creating dynamic dimension breaks
      2m 20s
    4. Making linear dimensions act like aligned dimensions
      2m 44s
    5. Finding dimensions with false values
      1m 38s
    6. Creating parent/child dimension styles
      4m 45s
    7. Making dimensions easier to read
      1m 56s
  6. 14m 40s
    1. Making global edits to attribute data
      4m 1s
    2. Clipping references using curved geometry
      2m 21s
    3. Exchanging one block symbol for another
      3m 3s
    4. Using drag-and-drop to insert content
      3m 17s
    5. Creating a block library in two clicks
      1m 58s
  7. 10m 42s
    1. Making global changes to layer names
      3m 19s
    2. Converting all object properties to BYLAYER
      1m 43s
    3. Navigating layer lists using the keyboard
      2m 5s
    4. Producing a hard copy of the layer settings
      1m 34s
    5. Removing stubborn layers
      2m 1s
  8. 25m 1s
    1. Accessing viewports within viewports
      3m 21s
    2. Creating viewports with islands
      6m 5s
    3. Creating legends using the Change Space tool
      3m 55s
    4. Rotating viewport content to match layout
      4m 55s
    5. Importing layouts from template files
      2m 3s
    6. Visualizing multiple design alternates
      4m 42s
  9. 30m 18s
    1. Consolidating backup files into a single folder
      2m 48s
    2. Launching applications from within AutoCAD
      3m 53s
    3. Creating custom linetypes
      5m 9s
    4. Incorporating symbols into custom linetypes
      2m 48s
    5. Salvaging data from a corrupt drawing
      3m 57s
    6. Applying hyperlinks to drawing objects
      3m 34s
    7. Converting drawings from name-based to color-based plot styles
      2m 0s
    8. Identifying the owner of a drawing
      1m 18s
    9. Incorporating drawings into PowerPoint presentations
      4m 51s
  10. 31s
    1. Goodbye
      31s

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
Please wait...
AutoCAD: Tips, Tricks, and Industry Secrets
3h 48m Intermediate Jan 31, 2011

Viewers: in countries Watching now:

In AutoCAD 2011: Tips, Tricks, and Industry Secrets, Jeff Bartels shows AutoCAD users how to become more efficient power users, reducing the amount of time it takes to accomplish a task, increasing profit margins, and strengthening marketplace competitiveness. The course covers everything from shortcuts used in geometry creation, to program customization, to real world solutions to common problems. Interface customization, block and reference management skills, and express tool usage are also covered. Exercise files are included with the course.

Topics include:
  • Creating macro enabled tools
  • Using Auto Complete
  • Disabling tool mode settings on the fly
  • Moving and copying entities using Windows shortcuts
  • Using the Calculator palette
  • Formatting text
  • Creating parent/child dimension styles
  • Making dimensions easier to read
  • Making global edits to attribute data and layer names
  • Exchanging one block symbol for another
  • Inserting content using drag and drop
  • Navigating layer list using the keyboard
  • Importing layouts from template files
  • Consolidating backup files
Subjects:
CAD 2D Drawing 3D Drawing
Software:
AutoCAD
Author:
Jeff Bartels

Creating macro-enabled tools

One place where you can save yourself some clicks is by creating a macro-enabled tool. Macros automate the way a command works, entering your favorite options automatically. In this lesson we're going to learn how to create a macro-enabled tool. On my screen I have a drawing of a plat of survey and I would like to purge this drawing and remove all of the unnecessary information. Let's see how many steps that is. First, I'll open the Application menu, then I'll come down to Drawing Utilities, and I'll select Purge.

I will then click Purge All, I'll select Purge all items, and I'll click Close. Now while that wasn't horribly time consuming, it was several clicks. Wouldn't it be nice if we could create a button that would purge the entire drawing in a single click? Well, this is where macros come in. A macro is nothing more than a line of text. Essentially, you create a text string that mimics what you would type at the command line, and then you create a button that plays back that text. So let's try that. I'm going to click on Undo to restore my purged items.

Since macros are text-based, they don't work too well with dialog boxes. So to create a macro for the Purge command, I'm going to run the text-based version of Purge. To do that, I'll type -purge and I'll press Enter. Notice I'm getting all of the same options. They are just available down here at the command line. As a side note, try putting a dash in front of other commands that invoke a dialog box. Commands like plot, or layer, or insert and you'll find that nearly every command can be driven using only text. All right! So I launched Purge and I pressed Enter.

Next, I'm going to press the letter A, because I'd like to purge all types of objects, and I'll press Enter. At the Enter name(s) to purge prompt, I'll press Enter because I'd like to purge all names. Finally, at the Verify each name to be purged prompt, I'll type the letter N and then I'll press Enter. As you can see, we can drive the entire command using only the keys on our keyboard. So the macros that we create will essentially match the buttons I just pressed. Once again I'm going to click Undo to bring back my purged information.

To create my macro, I'm going to launch the CUI command. I'll do that by clicking the Manage tab and then I'll select CUI. In the Command List area, I'll click the Create a new command icon. I can see my new command right down here in the Command List. Over here on the right, is a form that I can fill out related to this command. I'm going to start with the name. Let's call this purgeall. I will then click in the Description area and I will type in a description.

We'll say purges dwg in 1 click. This is what we'll see in the rollover tooltip when we hover over the icon. Next, I'll click in the Macro. This is our text string. Notice it already has some text in here, ^C^C. This essentially means Cancel, Cancel. This ensures that when I run my new command, AutoCAD will cancel any existing command that may already be running. I will then type my text string. I'll start with an underscore to let AutoCAD know I'm entering a command.

I will then type -purge, the same thing I tied to the command line, and now I have to simulate an Enter or a Return. There are two ways we can do this. I can use a space, or let me take that away. I can use the semicolon. The semicolon is probably the best choice, because if you have several enters in a row, they are visual. I can see several semicolons. It's easy to see multiple semicolons. After I launched the command and pressed Enter, I then type the letter A, because I want it to purge all objects, and I pressed Enter.

So I'll add another Semicolon. At this point, I pressed Enter again to accept the Asterix for the names to purge. Then AutoCAD asked me to verify each name, in which case I typed N and then I pressed Enter again. So this text string represents our macro for my one-click purge command. Now that I'm finished with my macro, let's assign an icon to this command. I can grab an icon from this list at the top. I'll pull this slider down and I'm going to select the standard purge icon to start with.

I will then come over here and click Edit and I can make changes to this image. Now this is the Button Editor. This is a very simplistic image editing tool. I have a couple of color choices over here on the left. I can freehand draw. I can draw some straight lines or circles. I have an erase tool. I can clear my icon. If I put a check in this box, I can display a grid that shows me the pixels in the icon. If you'd like to create really artistic icons, you can always create them in another application like Photoshop and you can click this Import button to bring them in.

I'm going to select the color red, and I am just going to create a big letter A here, for all. When I'm finished, I'll click Export and AutoCAD will take me into the default custom icons folder on my hard drive. I'm going to call my icon purgeall. Notice that AutoCAD is saving this as a BMP. Let's click Save. That default folder is the best place to save your icons, because eventually when you migrate your AutoCAD settings to the next version of AutoCAD, AutoCAD is going to look in that custom icons folder for any of your special symbols.

Now that I'm finished with my icon, I'll click Close, and AutoCAD is asking if I want to save changes. I'm going to click No, because I don't want to overwrite to the original icon image. Now let's assign our new icon symbols to the command. I'll do that down here in the Images area. As you can see, it's currently looking at the standard purge icon. Let me click in this field and I'll click the ellipses button, which takes me right back to that standard Icons folder. I'll select purgeall. Then, I'll click Open.

For the Large image, we'll use the same icon. Now that my command is finished, I'm going to click, hold, and drag, and I'll drop this up here in the Quick Access Toolbar. I can also drag this into a Ribbon panel like we saw in the previous lesson. When I'm finished, I'll come down and click OK. All right! Let's try out the new button. If I hover over this, so I can see it will purge the drawing in one click. Let me click the icon and that's it. The drawing has been purged. If I press F2 to bring up my command line history, let's roll up here.

I can see that AutoCAD launched the purge command and pressed Enter. It then typed the letter A for me and pressed Enter. It pressed Enter again at the asterix. Typed the letter N, and pressed Enter, and then it purged out all of the unnecessary information. Using this technique, we can create a custom automated macro for nearly any command. Now I'd like to do one more thing. Let's look at how we could create a macro that allows me to select a point on screen. For instance I'm going to move up and launch the Rectangle command.

When I launch Rectangle, the first thing AutoCAD asks me is to specify a corner point. So I'm going to click on screen. After I pick my point, 99% of the time I used the dimensions option. I type the letter D and hit Enter. I will then enter my dimensions. I will make this a length of 20 and a width of 5 and then I'll click onscreen to finish my rectangle. I would like to create a macro such that when I launch the Rectangle command, it will enter the dimensions option for me. Let's try that.

Once again, I'm going to return to the CUI. I'll click Manage, and then CUI. In the Command List area, I'll click Create new command. Then in the Properties area, I will give my command a name. I'll call this rectangdim. In the Description area, I will type "creates rectangles via dimensions." Now let's take a look at the macro. Cancel, Cancel. I'm going to keep that.

I'll enter an underscore and then I'll type rectang. This is the physical command that you would type at the command line to launch the Rectangle command. In fact, if you have any question about what the text version is for any command, simply launch it by clicking the icon, and take a look at the command line. For instance, we just launched CUI. You can see that we could also access that by typing cui at the command line. Now after I launch the Rectangle command, I press Enter. Then I have to pick a point on screen to have AutoCAD pause the macro such that I can pick a coordinate.

I'm going to use a backslash. After I pick my point, I'd like AutoCAD to enter the d option for dimensions, and then I'll press Enter. So I'll add another semicolon. Once again, let's grab an icon for our new command. I'm going to drag this down. You can select any icon you wish. I'm going to choose the standard rectangle command and I'll click Edit. Once again, I'm going to use the color red and I am just going to freehand draw a big D for dimensions.

That's good enough. When I'm finished, I'll click Export and we'll save this in the custom icons folder. Finally, I'll click Close and then I'll select No, because I don't want to overwrite the original icon. I will then assign this icon to my command using the ellipses button, and I will do that for both the small and the large image. Now that my command is finished, I will click, hold, and drag this command up to the Quick Access Toolbar and I'll click OK.

Okay, let's try it out. I will move up and click Rectangle. I will pick a point on screen and notice AutoCAD is asking me for my length. It entered the d for me automatically. I'm going to press Enter to accept the defaults and then I'll pick again to finish my rectangle. As you can see by creating macro- enabled tools, you can automate many of your repeated keystrokes, which over the course of the day can save you valuable time. Don't stop here either. See if you can link two or three commands together within a single macro.

There are currently no FAQs about AutoCAD: Tips, Tricks, and Industry Secrets.

Share a link to this course
Please wait... Please wait...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.
Upgrade now


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Upgrade now

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed AutoCAD: Tips, Tricks, and Industry Secrets.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Welcome to the redesigned course page.

We’ve moved some things around, and now you can



Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked

Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.