Categories

AutoCAD 2015 and AutoCAD LT 2015 Bible

The most comprehensive AutoCAD book around!

Switching among open AutoCAD drawings

You may have several drawings open at one time and want to switch between/among them. AutoCAD gives you several methods to do so. I can think of four.

Use the Windows taskbar

The Windows taskbar can show a separate button for each drawing. The system variable for this is, appropriately enough, TASKBAR. When set to 1, you’ll see a separate button for each drawing. Then you can easily click the drawing you want to display it. In Windows 7, the default value for TASKBAR is 1. However, in earlier versions of Windows, the default is 0, so you need to change the value if you want separate buttons. Just type taskbar, press Enter, type 1, and press Enter again.

Press Ctrl + Tab

Just press Ctrl + Tab to cycle among your drawings. Thanks for Franck Wallez for this tip.

Use Quick View on the status bar

Click the Quick View Drawings button on the right side of the status bar. You’ll see a display like this.

AutoCAD tip: Switch between drawingsClick the thumbnail of the drawing you want to display.

Application button list of open drawings

Click the Application button at the upper-left corner of your screen. By default, you see a list of recent drawings. Click the Open Documents icon to see a list of open drawings and choose the one you want to display.

AutoCAD tip: Switch between drawings

Which method do you use? Does it depend on the situation? Do you sometimes want to see a thumbnail of the drawing? Which method do you think is fastest?

Tested in AutoCAD 2012

 

Squeeze or stretch single-line text to fit in a space with TEXTFIT

The TEXTFIT command lets you easily squeeze or stretch existing single-line text (TEXT or DTEXT) so you can fit it into a defined space, such as a title block.

TEXTFIT doesn’t work with multi-line text (MTEXT).

When you start the command, you select the single-line text and TEXTFIT puts a drag-line under the text. Just pick the desired endpoint and you’re done. If you want to change the start point of the text, use the Start Point option, pick a start point and then an end point.

Watch the video to see how it works.

TEXTFIT works with existing text, but you can fit single-line text into a space when you create it, using the Align or Fit Justify options. Here are the steps:

  1. Start the TEXT command.
  2. At the Specify start point of text or [Justify/Style]: prompt, type j and press Enter.
  3. At the Enter an option [Align/Fit/Center/Middle/Right/TL/TC/TR/ML/MC/MR/BL/BC/BR]: prompt, type a for the Align option or f for the Fit option and press Enter.
  4. At the Specify first endpoint of text baseline: prompt, specify a start point for the text.
  5. At the Specify second endpoint of text baseline: prompt, specify an endpoint. You may want to turn on Ortho before specifying the endpoint.
  6. If you chose the Fit option, it asks you to specify a height. This option maintains that height, distorting the letters if necessary. The Align option changes the height of the text to maintain the proportion of the letters.
  7. Type your text and press Enter twice to end the command.

Thanks to Tommy Holden for the part of this tip relating to TEXTFIT.

 

Select objects: prompt secrets

When you start an editing command, you see the Select objects: prompt. But AutoCAD doesn’t explicitly tell you how to select those objects. In fact, this prompt has hidden options that you should know.

AutoCAD tips-Select objects prompt secretsHere’s a list of some of the most useful.

Last

One that I use often is Last. It selects the most recently created object. It’s so common to create an object and then need to move or copy it. So I just start the editing command, type l and press Enter at the Select objects: prompt, press Enter again to end selection and continue.

Previous

Type p at the Select objects: prompt to select the same objects that you selected in the previous editing operation.

All

The All option selects all objects on thawed and unlocked layers in the drawing. It only selects objects in your current space (model or paper). It’s really helpful for making mass changes. Just type all and press Enter. You can’t just type a, because that’s the Add option, which I explain in the next section.

Remove and Add

Sometimes you select too many objects and want to remove an object or objects from the selection set without starting over. You can type r and press Enter, then start selecting objects to remove. If you then need to add objects to the selection set, type a and press Enter.

However, pressing Shift and selecting an object has the same effect as the Remove option and I find that simpler.

You can also remove the last object you added to the selection set with the Undo option. (But if the last action you took was removing an object from the selection set, Undo adds it!)

What are your hidden selection tips?

 

Keep track of what you’ve done with COPYHIST

Thanks to Tommy Holden for this tip.

AutoCAD allows you to copy the command line history window to the clipboard by using the COPYHIST command. The command line history is the window just above the command line. This way you can keep track of previous commands already executed in case you want to:

  • Repeat what you did
  • Not repeat what you did
  • Just see what you did

After typing COPYHIST and pressing Enter, simply go to another Windows application and paste in the information.

COPYHIST is also a useful tool for troubleshooting.

Here’s a sample.

 

Do you use COPYHIST? What do you use it for?

Avoid reselecting objects in editing commands that go wrong

Have you ever had an editing operation go wrong? You know, you select the objects and move them, but AutoCAD snaps to the wrong location and now they’re all in the wrong place.

Or have you selected some objects, and moved them, only to find that you moved more objects than you want to — or left some behind?

Of course, this happens to all of us.

Brian Glover offers this time-saving tip and it works for all releases of AutoCAD as far back as I can remember.

Undo the command (Ctrl + Z is the easiest way).

Restart your editing command.

At the Select objects: prompt, type p and press Enter. You’ll have the same objects selected again.

If your objects ended up in the wrong place, just be more careful this time when choosing the destination.

If you left out objects, just select them now. If you included too many objects, press Shift and left-click (pick) them to remove them from the selection set.

You can retrieve previous selection sets for COPY, MOVE, STRETCH, ROTATE, SCALE, MIRROR and DRAWORDER. Let me know if it works for other editing commands–leave a comment!

Change the font of a text style using AutoLISP

This is a guest post by Sanjay Kulkarni, an AutoCAD programmer. You can read more about him at the end of this post.

In the current era of globalization, many times you may have to work on drawings received from others. Sometimes, you may not be able to control the quality of the drawings you receive. In such a situation, you may have to carry out a repair job on the drawings. Such tasks can be made less tedious if you standardize these tasks and carry them out using AutoLISP.

One of my Indian clients receives drawings from their European principals. One of the repair jobs is to change the font of the text inside dimensions, attributes, tables & notes. Since all these texts are included inside their respective block, the task becomes more complicated than is really necessary.

Most of the text, however, is controlled by the text style. Thus, the job is really to change the font in the text style. But there are a handful of the text styles. So, it becomes a time consuming task.

I helped them with a simple AutoLISP function that made this job virtually painless. The function changes the association of a text style from existing font file to another font file. The function takes 2 parameters, the name of the existing text style and the name of the font file that will be associated with the text style.

You can download the function here.

How to use the AutoLISP function

This function can be used like this:

(chngFontOfTxtStyle “<TextStyleName>” “<DifferentFont.xtn>”)

As you may have noticed, this function can be used only inside another AutoLISP program. This calling AutoLISP program can provide the user interface that you may need. Following are a couple of sample situations that you can build around this function.

1. Ask the user to type the names of the text style and font file and store them in variables. Call the above function with these two variables as parameters.

2. Ask the user to type the name of the font file. Browse programmatically through all the text styles and repeatedly call the above function with name of each text style and name of the font file as parameters. This will change the font of all text styles.

As you can see, there is no limit to the situations you can build and keep using the function.

For example, you could enter the following on the command line:

(chngFontOfTxtStyle “Something Funny” “arial.ttf”)

In this case, the name of the text style is Something Funny and you want to change the font to Arial.

How to get help for the function

Also note that this function has built in help. The message is displayed as soon as you load the lisp file to type cfot? (note the use of ? to indicate help) at the command prompt. If you type this, minimal help is displayed at the command prompt.

How do you know that the font name association was successfully changed? As described in help, the function returns 0 if successful or -1 if not. You will need to check the return value.

What other tasks do you want to automate?

Are you stuck-up with such trivial tasks that are strain on your resources. Let me know directly (my email is below) and we’ll see if I can help you with useful hints or sample code. Or you can post a comment.

Sanjay Kulkarni is an experienced CAD (AutoCAD, Inventor, SolidEdge, CATIA, NX) programmer and a member of the Autodesk Developer Network. He is fluent in AutoLISP, VBA, and VB.NET. He has written for AugiWORLD and Inside AutoCAD (a monthly magazine that has since gone out of publication). He can be contacted at sanganaksakha@gmail.com

 

Keep your own styles, layers & blocks at the top of the list

You’re always creating styles — text, dimension, etc. — layers, and blocks. But when you open the Layer Properties Manager or any other list with these items, they are alphabetized. Especially if you’re sharing drawings with others who add their own styles, layers, and blocks, what can you do to make it easier to find “your own stuff?”

Thanks to Franck Wallez for this tip! He says:

I like to have my own little creations, such as my dimension or text style, my layers, and my blocks,  always easily accessible. I took the habit of starting their name with the underscore _ character, because  then they are are always at the beginning of the lists and not down somewhere in the middle.

He cutely adds, “Please do not use this trick or I will have to use two underscores to stay at the top!”

What naming conventions do you use to help you find your styles, layers and blocks more easily?

Draw fast, accurate revision clouds

Revision clouds show areas of a drawing that have been recently revised. When the REVCLOUD command was introduced to AutoCAD, I thought that they were for quick and dirty indications of revised areas of a drawing. Then I saw that people liked them to be neat!

If you like neat over messy, here’s the technique. Thanks to Brian Glover for contributing this tip.

  1. Draw the extents of the revision cloud using the POLYLINE, RECTANG, or CIRCLE command.
  2. Start the REVCLOUD command. AutoCAD displays the current minimum and maximum Arc settings.
  3. To change current settings, type A and press Enter. Follow the prompts to enter minimum and maximum settings. Size your arcs according to your page size. For 8-1/2″x 11″ (or an A sheet), use 1/8″ (about 3mm) and 1/4″  (about 6mm). For a 24″ x 36″ (or a D sheet), use 1/2″ (about 13mm) and 3/4″  (about 19mm) arcs.
  4. The default option is Object, so press Enter and select the object you draw around the revised area.
  5. At the Reverse Direction [Yes/No]: prompt, press Enter for No (if the revision cloud looks right) to end the command. If the cloud arcs are the opposite direction from what you want, type Y and press Enter.

autocad_tips-neat-revclouds-1Note: You can only convert one object to a revision cloud at a time. The REVCLOUD command works on any polyline (closed or not) or circle.

Draw and edit faster and easier with these top 25 productivity tips every AutoCAD user should know. Check out “Top Productivity Tips Every AutoCAD User Should Know” at http://www.ellenhelps.me/25-Productivity-Tips

Manage embedded shapes (islands) when hatching in AutoCAD

It’s common to have closed figures inside other closed figures in AutoCAD drawings. When you hatch these shapes, you can specify whether or not the inner figures are also hatched. This becomes most important when you have 3 closed figures, one inside the other. In fact, you have 3 options for islands.

To set the options in AutoCAD 2011 and 2012, start the HATCH command to display the Hatch Editor tab. Expand the Options panel and choose an option from the Island Detection drop-down list.

autocad_tips-hatch-islands-2

In earlier releases, expand the Hatch and Gradient dialog box by clicking the right arrow at the lower-right corner. In the Islands section, choose one of the options.

Here is the result of each option.

Outer Island Detection only hatches the outer-most closed shape.

autocad_tips-hatch-islands-1

Normal Island Detection alternates between hatched and not hatched areas.

autocad_tips-hatch-islands-3Ignore Island Detection ignores islands and hatches everything.

autocad_tips-hatch-islands-4Note that text is counted as an island and isn’t hatched, even if the island option would normally hatch the island. This example was done with Normal Island Detection, which would have hatched a circle, but the text wasn’t hatched.

autocad_tips-hatch-islands

Understanding how dimensions are associated with objects

autocad_tips-dimensions-objects-1

This is a guest post by Sanjay Kulkarni, an AutoCAD programmer.

Learning AutoLISP (or any other programming language) doesn’t compel you to become a programmer. You can still use it to better understand the internal working of AutoCAD and enhance your interactive working skill. This can also give you an edge over others.

Recently I received a client’s drawing that was in AutoCAD 2004. Even when I saved it in AutoCAD 2010, the dimension would not adjust when I changed the length of a line. Only after I recreated the dimension was I able to use this capability. The reason, I found, was that the dimension in AutoCAD 2004 did not have the reactor (discussed below). Only when I created the dimension in AutoCAD 2010 was the reactor added.

Let’s learn this lesson with an example

Everybody knows that when you dimension an object, the dimension automatically updates when you modify the object. Have you ever wondered how the dimension knows it has to update? AutoLISP can help you find this out, if you don’t already  know.

Here’s the example:

1. Draw a line.

2. Get its entity list by typing the following piece of AutoLISP code at the command prompt:

(entget (car (entsel)))

and selecting the line when prompted to select an object. You’ll see something similar to the following at the command line in return.

((-1 . <Entity name: 7ee45a18>) (0 . “LINE”) (330 . <Entity name: 7ee43cf8>) (5 . “22B”) (100 . “AcDbEntity”) (67 . 0) (410 . “Model”) (8 . “0″) (100 . “AcDbLine”) (10 10.0 10.0 0.0) (11 160.0 160.0 0.0) (210 0.0 0.0 1.0))

This, you might have guessed, is the record that AutoCAD stores in its database.

3. Create a dimension (aligned for example) to show the length of the line and get the entity list of the line again. You should get a result similar to:

((-1 . <Entity name: 7ee45a18>) (0 . “LINE”) (5 . “22B”) (102 . “{ACAD_REACTORS”) (330 . <Entity name: 7ee45ae8>) (102 . “}”) (330 . <Entity name: 7ee43cf8>) (100 . “AcDbEntity”) (67 . 0) (410 . “Model”) (8 . “0″) (100 . “AcDbLine”) (10 10.0 10.0 0.0) (11 160.0 160.0 0.0) (210 0.0 0.0 1.0))

You might have noticed a new item starting with (102 . “{ACAD_REACTORS”) (330 . <Entity name: 7ee45ae8>) (102 . “}”) in the entity list of the line.

This is a reference to a reactor object that AutoCAD has created after adding the dimension. This reactor ensures that dimension gets modified when the object (line in this case) gets modified.

A reactor is a program that executes automatically when a particular action (change in the length of line in this case) is completed. A reactor executes only AFTER an editing action is completed. Hence, you see that the dimension is modified after the command that modifies the line completes and is not dynamically updated while length of line is being modified.

4. Next, entget the dimension using the same code but selecting the dimension this time.  You will get something similar to:

((-1 . <Entity name: 7ee45a20>) (0 . “DIMENSION”) (5 . “22C”) (102 . “{ACAD_XDICTIONARY”) (360 . <Entity name: 7ee45a90>) (102 . “}”) (102 . “{ACAD_REACTORS”) (330 . <Entity name: 7ee45ae8>) (102 . “}”) (330 . <Entity name: 7ee43cf8>) (100 . “AcDbEntity”) (67 . 0) (410 . “Model”) (8 . “0″) (100 . “AcDbDimension”) (280 . 0) (2 . “*D6″) (10 173.511 146.489 0.0) (11 98.5106 71.4894 0.0) (12 0.0 0.0 0.0) (70 . 33) (1 . “”) (71 . 5) (72 . 1) (41 . 1.0) (42 . 212.132) (73 . 0) (74 . 0) (75 . 0) (52 . 0.0) (53 . 0.0) (54 . 0.0) (51 . 0.0) (210 0.0 0.0 1.0) (3 . “Standard”) (100 . “AcDbAlignedDimension”) (13 10.0 10.0 0.0) (14 160.0 160.0 0.0) (15 0.0 0.0 0.0) (16 0.0 0.0 0.0) (40 . 0.0) (50 . 0.0))

You will notice that exactly same reactor appears in the entity list of dimension. Thus, this reactor is the link between the line and dimension.

5. Add one more dimension to the line and get the entity list of line once more. You will see one more item with (330 . in the reactor reference. Thus each dimension associated with line is added as an item with 330 dxf code in the entity list of line..

6. Now delete one of the dimensions and get the new entity list of the line. You will find that one of the (330 . item has been removed.

7. After you delete all dimensions, the entity list of the line returns to its original form without any (102 . items.

A possibility to improve associativity

It is interesting to note that when object is deleted, dimension does not get deleted. Thus it lacks true associativity with the object.

You could create a situation whereby the dimension would be deleted when the object was deleted by adding a reference to one more reactor in the dimension’s entity list that responds to deleting its associated object, but you would have to write code to do so.

Sanjay Kulkarni is an experienced CAD (AutoCAD, Inventor, SolidEdge, CATIA, NX) programmer and a member of the Autodesk Developer Network. He is fluent in AutoLISP, VBA, and VB.NET. He has written for AugiWORLD and Inside AutoCAD (a monthly magazine that has since gone out of publication). You can contact him at sanganakskha@gmail.com.