Categories

AutoCAD 2012 & AutoCAD LT 2012 Bible

The most comprehensive AutoCAD book around!

AutoCAD 2012 Bible

Repeat an AutoCAD command automatically

You probably know that after you execute an AutoCAD command, you can press Enter to repeat it.

But it might be quicker to set a command to repeat automatically, if you know in advance that you’ll use it a number of times in a row.

Some commands repeat automatically. In a sense, the LINE command does this, prompting you automatically for a new segment. and the COPY command prompts you to create additional copies. For more information, see my tip, “Changing the Multiple options of AutoCAD commands (or sometimes you feel like a multiple option, sometimes you don’t).”

Brian Glover wrote a tip about another way to repeat commands–typing multiple (and a space) before typing a drawing command.

Did you know that you can force a command to repeat itself after you finish using it? Sure there are some commands already that have multiple functions. The LINE command is a good example. Start the command, pick your first point, the next point and the next until you are done entering points and press the escape key to end the command. To draw more lines, you have to start the command again.

Unless you entered the MULTIPLE command in before you start the LINE command. Now you draw your first line, but when you press the Escape key, the LINE command starts again and you are prompted for the first point of the line. When you are completely finished drawing lines, press the Escape key a second time to end the MULTIPLE command.

This command works with all drawing commands (Arcs, Circles, Ellipses, Lines, Rectangle, etc.), Text commands, Match Properties, and even the COPY command. Please note, that it does work with the Dimension commands, but unless you are entering multiple, separate dimensions, it is better to use the DIMENSION CONTINUE command.

Remember, after using MULTIPLE before a command, when you want to stop repeating, press the Escape key. So, go ahead and make lots of arcs or rectangles. You’ll be able to do it a little faster now.

How to lock AutoCAD’s user interface

This is a guest blog post from .

It’s happened to all of us. A car outside backfires, a door slams or a cheeky college sneaks up behind you and gives you a tickle; before you know it your AutoCAD user interface is a mess!

If you’ve invested a lot of time setting up AutoCAD’s UI the way you like it, I seriously recommend that you save your user interface as a custom workspace.

However, I have another quick tip to share with you that can prevent your Ribbon tabs, Toolbars or Tool palettes accidentally being nudged around the screen.

Locking the User Interface

The secret is the little padlock icon down in your system tool tray. Clicking on this little button will lock down AutoCAD’s user interface, so that you can’t accidently move anything.

Tip: If you can’t see the control, click on the arrow at the far end of the system tool tray and select Display Locking.

autocad_tips_lock-autocad-user-interface-2

Locking separate elements of the User Interface

Clicking on the Lock UI button gives you a few choices about which UI elements you want to lock.

  • Lock all controls
  • Lock only floating Toolbars or Ribbon panels
  • Lock only docked Toolbars or Ribbon panels
  • Lock only floating windows*
  • Lock only docked windows*

*In this case ‘Windows’ refers to controls such as the Ribbon, the Design Center, and the Properties palette.

autocad_tips_lock-autocad-user-interface

You can also type lockui at the command line to access the User Interface locking settings. The LOCKUI setting is stored as a bitcode using the sum of the following values:

  • 0    Toolbars and windows not locked
  • 1    Docked toolbars locked
  • 2    Docked or anchored windows locked
  • 4    Floating toolbars locked
  • 8    Floating windows locked

But what if I WANT to move a control?

Here is one more quick tip for you. If you have your AutoCAD User Interface locked down, and you just want to nudge one control out of the way – simply hold down the CTRL key while you drag the Tool bar, Tool palette or Ribbon tab to temporarily allow moving and re-sizing of the control.

I hope that you’ve enjoyed this quick tip, now – LOOK BEHIND YOU! (Tickle, tickle)

  is the writer of The CAD Setter Out, supplying tips, tricks and tutorials for Drafters using AutoCAD and Autodesk Inventor to create drawings for the construction industry. In his spare time Paul enjoys Drawing and Woodworking. He thinks that modelling his Joinery designs in 3D is the most fun anyone can have, by themselves…

Get the best price on technology purchases — and anything else!

Do you buy electronics and more on Amazon, Newegg, or other sites? If so, I’d like to introduce you to a new, free service that will help you get the lowest price.

Many people don’t realize that prices fluctuate constantly, particularly on websites like Amazon, which allow third party vendors to continually undercut one another.

For example, consider the price variations for a Samsung 59-Inch 1080p 3D Plasma HDTV over three months (Jul 10 to Oct 10, 2011):

$1,850, 2,251, 1,920, 2,000, 2,251, 2,145, 2,218, 2,225, 2,145, 2,200

You could have spent as much as $2,251 — or as little as $1,850!

Wouldn’t it be great if you could catch these price fluctuations at their lowest point? Now you can, with a free, easy to use tool called BuyLater (install it in seconds at www.BuyLater.com). BuyLater is a browser extension (compatible with Firefox, Chrome, and Safari) that adds a button to Amazon and numerous other shopping websites. Simply click the BuyLater button to track an item and you will receive an email when the price drops. The best part is that you don’t ever have to leave the site you’re shopping on.

BuyLater supports many websites, including Amazon.com, Walmart.com, Newegg.com, and more. New websites and features are added frequently, and the development team loves suggestions.

BuyLater is a great tool for anyone who shops online. You can track prices on Amazon and other websites for every type of product imaginable. BuyLater is especially useful when you’re waiting to make a large purchase. For example, the price for a Cartier Women’s Pasha Stainless-Steel Ceramic Black Dial Watch over three months (Jul 10, 2011 to Oct 10, 2011) has ranged from $4,092 to $3,783! — a variance of $309!

BuyLater makes it easy to be an informed shopper and save where it counts, which means that you can focus less on shopping and more on what you love. I’ve used it to track food items, soy candles, electronics, and more and was amazed at how often the prices changed.

Why is it free? The company makes its money as an affiliate of Amazon (and other sites that offer an affiliate program), so you pay nothing!

Here’s my take on it. Just as buyer reviews on Amazon and other sites have changed the way you decide what you buy, BuyLater will change when you buy.

Oh, and if you install BuyLater by November 30th, you will be entered to win $500 cash!

Full disclosure: My son is one of the developers of BuyLater and I’m one proud mama!

 

Reduce mouse-clicks and increase productivity 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.

The number of mouse-clicks required to perform a task is generally a good indicator of productivity. The fewer the number of clicks, the less time required–hence more productivity.

In this post we will see an example of reducing the number of mouse-clicks, and thus improving productivity, using AutoLISP. We will use the example of the FILLET command.

Thanks to one of the blog readers Bruce Newman, who sent a problem to me. It was the source for this post.

The most simple situation where you create a fillet is when two perpendicular lines meet. Inside the FILLET command, you select the two lines (requiring 2 clicks) and AutoCAD creates the fillet.

Reducing clicks and increasing productivity in AutoCAD with AutoLISP

 

The equivalent AutoLISP code would be

(command “fillet” (car (entsel “\nSelect the first line: “))(entsel “\nSelect the second line: “)))

This still requires two clicks.

So, the problem now reduces to finding a method to select two lines with a single click.

Before trying in AutoLISP, let’s find out if we can do it manually. There seems to be no option or a work-around to do what we want.

Luckily, we have a single point (the intersection) that is common to both lines. So, let’s explore if we can somehow use the intersection point to select the 2 lines. If you have to click only one point to select multiple objects, obviously it should be the intersection point.

Study of selection methods shows that there are two options that base their selection on two points: crossing & window. Since W must include the objects fully, it won’t be suitable. So let’s try C option.

Use the SELECT command and then the c option and click on the intersection point in response to both points. AND …….. Both lines are selected!

The equivalent AutoLISP code would be

(setq ssLines (ssget “c” (setq pt1 (getpoint “\nSelect Intersection: “) ) pt1))

Now I can use each line to create a fillet.

(command “fillet” (ssname ssLines 0) (ssname ssLines 1))

And yes … the fillet appears!

Reducing clicks and increasing productivity in AutoCAD using AutoLISP

 

So, here is my simple program:

(defun c:FiletByPt ()

;;; creates fillet by single click

;;; ssk 110918

(setq ssLines (ssget “c” (setq pt1 (getpoint “\nSelect Intersection: “) ) pt1))

(command “fillet” (ssname ssLines 0) (ssname ssLines 1))

)

(prompt “\nCreates a fillet by single click. Type ‘FiletByPt’”)

Note: In the command name above, FiletByPt, “fillet” is intentionally spelled “filet” to avoid confusion as you start to type the custom AutoLISP command.

To use the above code, copy and paste it into Notepad and save it as filetbypt.lsp in a location that is in AutoCAD’s support file search path. Instructions for loading the program are here.

However life is always not so simple. The lines may extend beyond the intersection point. My R&D shows that the above code still works as shown in Fig. 3.

AutoCAD tip: Reduce clicks and increase productivity in AutoCAD with AutoLISP

It even works when the two lines are not perpendicular.

When two lines are selected using a single point, AutoCAD finds and trims shorter segments of each line and then creates a fillet between the two remaining segments.

There might be situations (when two lines meet at the midpoint) where the code may not work or possibly needs modification.

But, if creating fillets is a major task for you, and saving 50% of time can result in significant gain, go ahead and use this code.

Are you stuck-up with such trivial tasks that are strain on your resources? Let me know and we’ll see if I can help you with useful hints or sample code.

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. He can be contacted at sanganaksakha@gmail.com

 

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

In a recent post, “Avoid reselecting objects when editing commands go wrong,” I wrote about using the Previous option when you have the Select objects: prompt. (This was from a tip contributed by Brian Glover.)

AutoCAD tips-Select objects prompt secretsBased on the comments, I realized that other hidden selection options might be useful to you as well.

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.

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