AutoLISP offers powerful programming capabilities to AutoCAD, but you don’t need to be a programmer to use it. You can fairly easily create a simple custom command that can make your work go more quickly. In this tutorial, you’ll create a custom command that draws a red circle in any location and with any radius. You could use it to encircle areas where corrections need to be made.
Open Notepad.
Type the following:
(defun c:redcircle (/ center pt-on-circumference)
(terpri)
(setq center (getpoint “Specify center of red circle:”))
(terpri)
(setq pt-on-circumference (getpoint center “Pick a point on the circumference:”))
(command “_circle” center pt-on-circumference)
(command “_chprop” “_last” “” “_color” “red” “”)
)
Save the file in a folder that is in your support file search path. Name it redcircle.lsp (not .txt, the default for Notepad).
In AutoCAD, choose Manage tab> Applications panel> Load Application (the APPLOAD command) to open the Load/Unload Applications dialog box.
Choose redcircle.lsp and click Load. You should see the message: redcirle.lsp successfully loaded at the bottom of the dialog box.
Click Close.
On the command line, type redcircle and press Enter.
At the Specify center of red circle: prompt, specify the circle’s center.
At the Pick a point on the circumference: prompt, pick a point on the desired circumference to specify the radius.
AutoCAD draws the circle and immediately makes it red.
How does it work?
Here’s a line-by-line explanation:
(defun c:redcircle (/ center pt-on-circumference): Everything in AutoLISP is enclosed in parentheses, so you start with an open parenthesis. (You’ll close it at the very end of the routine.) defun followed by c: creates a custom command. Then add the name of the command. The parentheses after the command name are for variables that you’ll define. In this case, they are center and pt-on-circumference. The forward slash and space just have to be there.
(terpri): This function makes the upcoming prompt go on a new line so it’s easy to read.
(setq center (getpoint “Specify center of red circle:”)): The setq function means you’re defining a variable. Its name is center. Then you need another open parenthesis for getpoint which lets the user specify a point. After that is the prompt in quotation marks. You can put anything you want; it should be self-explanatory to the user. After that, you need to close both sets of parentheses.
(setq pt-on-circumference (getpoint center “Pick a point on the circumference:”)): Here again, you’re defining a variable, pt-on-circumference, and getting the point from the user. The only part that isn’t obvious is putting the center variable after getpoint. But you need to do this to create the rubberband line from the center; this is how AutoCAD measures the radius.
(command “_circle” center pt-on-circumference): Using the command function accesses AutoCAD’s regular commands. The underscore before circle allows for translation; it isn’t necessary. You put the command name in quotation marks. Then you give AutoCAD the information it needs to create the circle, namely the center and radius (specified by a point on the circumference). The AutoLISP routine applies the values you gave the variables when you picked the 2 points.
(command “_chprop” “_last” “” “_color” “red” “”): We now use the CHPROP command to make the circle red. This command is just perfect for AutoLISP routines where you want everything to be on the command line, rather than on the ribbon or in a dialog box. Then, you specify the last object created; this is applied to the Select objects: prompt. The 2 empty quotation marks end selection. Then you use the Color option and specify read as the color. All the options go in quotation marks. The final empty quotation marks end the command.
): This closes the first open parenthesis and ends the routine.
How do you use the routine?
Save the file with a filename extension of .lsp in a folder that’s in AutoCAD’s support file search path. If you don’t know how to load an AutoLISP file, see “How to load an AutoLISP program” and “How to load an AutoLISP program quickly.” Then just type the name of the command you created (in this example it’s REDCIRCLE) on the command line.
What else can you create?
Try creating an AutoLISP routine that draws a blue line.
Leave a comment and let us know what custom commands you created!
Suppose that you want to quickly change the layer of all objects on your WALL layer. Or, you want to change the linetype of all blocks named “dormer” that use the Hidden linetype. Here’s a quick way to select the objects you need.
The SELECTSIMILAR command (starting in AutoCAD 2011) allows you to select objects in a drawing that are similar to a selected object. Follow these steps:
To use the default settings, select one or more objects, then right-click and choose Select Similar from the shortcut menu.
Or, to specify set5tings, type selectsimilar, press Enter, and select one or more objects. Press Enter to end selection. At the Select objects or [SEttings]: prompt, use the Settings option to open the Select Similar Settings dialog box.
Choose the properties you want for similarity.
Click OK to close the dialog box and select the objects.
Start an editing command. The objects remain selected so you can apply that command to the selected objects.
Using the SELECTSIMILARMODE system variable
The SELECTSIMILARMODE system variable lets you preselect which settings AutoCAD uses when you select an object and use the SELECTSIMILAR command without opening the dialog box. The value is a bitcode, which means that it is the sum of the options you choose. The default is 130, which is 2 (layer) + 128 (name).
Here are the bitcode values you can use:
0
Object type
1
Color
2
Layer
4
Linetype
8
Linetype scale
16
Lineweight
32
Plot style
64
Object style, including text styles, dimension styles, and table styles
128
Name, for referenced objects including blocks, xrefs, and images
When you have the block definition in your drawing (perhaps you just created it), follow these steps to insert it:
Go to Home tab> Block panel> Insert to start the INSERT command and open the Insert dialog box.
From the Name drop-down list, choose the block that you want to insert. The list contains the names of all the blocks in the drawing.
In the Insertion Point section, you would usually leave the default setting, which is to specify the insertion on-screen. However, if you know the coordinates, you can deselect that option and enter the coordinates. You might do this for a title block that you want to insert at 0,0.
In the Scale section, you can pre-specify a scale. By default, the Specify On-screen option is not checked. You’ll still be able to specify the scale after you return to your drawing, but before you specify the insertion point. Again, if you know the scale you want, you can enter X, Y and Z scale factors in this section. By default, the Uniform Scale checkbox is checked, which means that the same scale will be used for X, Y and Z directions. Uncheck this checkbox to use varying scales for the 3 dimensions.
In the Rotate section, you can pre-specify a rotation angle. By default, the Specify On-screen option is not checked. You’ll still be able to specify the rotation after you return to your drawing, but before you specify the insertion point. Of you know the rotation you want, you can enter an angle in this section.
Sometimes, you may want to explode the block when you insert it. For example, you might want to change the block. Of course, you can explode the block after insertion, using the EXPLODE command, but the Insert dialog box gives you a shortcut. Just check the Explode checkbox at the lower-left corner.
Click OK to close the dialog box and return to your drawing.
At the Specify insertion point or [Basepoint/Scale/Rotate]: prompt, specify the insertion point for the block. The base point of the block (which you specified when you created the block) will go at the insertion point. You can also use the following options:
Basepoint: Freezes the location of the block to let you temporarily change the block’s basepoint. Keep the cursor in the drawing area as you do this, so you can specify the new basepoint.
Scale: Lets you specify a scale factor
Rotate: Lets you specify a rotation angle
Note: In the Insert dialog box, the path and block unit information are not editable. The Locate Using Geographic Data is only available if you have added geographic data to the drawing and if the block (in this case another drawing) also has geographic data.
Insert another AutoCAD drawing as a block
To insert another drawing as a block, follow these steps:
Open the Insert dialog box as just described and click the Browse button. For example, you may have created blocks as individual drawings which are part of a block library.
Navigate to the drawing, select it, and click Open. You’re now in the Insert dialog box.
Use the dialog box settings in the same way you would for a block inside your drawing and click OK.
At the Specify insertion point or [Basepoint/Scale/Rotate]: prompt, specify the insertion point for the block, using the options if you want.
It’s always wiser to reuse work you’ve done than to recreate it from scratch. You spend spend time creating layers and you shouldn’t have to do it again.
Use the DesignCenter to access layers
An easy way to get layers from another drawing is to use the DesignCenter. Follow these steps:
Press Ctrl+2 to open the DesignCenter.
In the Folder List pane, navigate to a file that contains the layers you want and double-click it to expand its components.
Click Layers to display the layers in the right-hand pane.
Drag the layer you want onto the drawing area.
You can now see that layer in the Layer list on the Home tab.
Content Explorer
You can also use the Content Explorer to access layers from other drawings. I explain how to use the Content Explorer here. The process is the same; you navigate to a drawing in a “watched folder” and drag the layer onto the drawing area.
Save a template
Once you know the layers you need, you should save them in a template. Follow these steps:
Delete any objects in the drawing; you want only the settings, such as units, layers, etc.
Choose Application button> Save As.
From the File of Type drop-down list, choose AutoCAD Drawing Template (*.dwt). The Save In folder (at the top of the dialog box) automatically changes to your Templates folder.
In the File Name text box, type a name for your template.
In the Template Options dialog box that opens, type a description if you want. You can also choose if new layers come in as unreconciled (warning you of new layers) or not.
Click OK.
Close the template that you saved.
To use the template, choose Application button> New to open the Select Template dialog box. Your new template will be there.
Choose it and click Open. Your new drawing now has all the layers that you saved in the template.
Baseline and continued dimensions are linear dimensions that are based on an existing linear dimension:
Baseline: The second and subsequent dimensions all start at the same point as the existing dimension but end at a different point
Continued: The second dimension starts at the end point of the existing dimension
Create a baseline dimension
First, create a linear dimension. Then, go to Annotate tab> Dimensions panel and click the Continue drop-down list, choosing Baseline. This starts the DIMBASELINE command. You see the Specify a second extension line origin or [Undo/Select] <Select>: prompt.
If you just drew a linear dimension, AutoCAD remembers that and you can simply specify the endpoint of the new baseline dimension. The command automatically uses the start point of the existing linear dimension as the start point for the baseline dimension.
If you drew the linear dimension at some other time, press Enter to use the Select option. At the prompt, select the existing linear dimension that you want to use. To get accurate results, pick the existing dimension closest to the end that you want to use as the baseline. Then you can go on to specify the endpoint of the new baseline dimension.
You can continue to place more baseline dimensions. Press Enter twice to end the command.
A baseline dimension
Create a continued dimension
First, create a linear dimension. Then, go to Annotate tab> Dimensions panel and click the Continue drop-down list, choosing Continue. This starts the DIMCONTINUE command.
If you just drew a linear dimension, you see the Specify a second extension line origin or [Undo/Select] <Select>: prompt. You can simply specify the endpoint of the new baseline dimension. The command automatically uses the endpoint of the existing linear dimension as the start point for the continued dimension.
If you drew the linear dimension at some other time, you see the Select continued dimension: prompt. (If you see the Specify a second extension line origin or [Undo/Select] <Select>: prompt, press Enter.) Select the existing linear dimension that you want to use; it doesn’t have to be a continued dimension. To get accurate results, pick the existing dimension closest to the end that you want to use as the beginning of the continued dimension. Then you can go on to specify the endpoint of the new continued dimension.
You can continue to place more continued dimensions. Press Enter twice to end the command.
Continued dimensions
Note: Although the most common baseline and continued dimensions are linear, you can also create them for angular and ordinate dimensions.
As with other dimensions, always use an object snap to specify the endpoint of the baseline dimension.
Do you have tips for drawing accurate baseline and continued dimensions? What other types of dimensions do you draw? Ordinate? Inspection? Tolerances? Please share by leaving a comment!
Measuring angles can be challenging. Sometimes, two lines that create an angle don’t even intersect or intersect, but not at their endpoints. For this reason, specifying an accurate vertex for the angle is important.
To dimension an angle, start the DIMANGULAR command. You can get there in two ways:
Home tab> Annotation panel> Dimension drop-down list> Angular
You see the Select arc, circle, line, or <specify vertex>: prompt. You can respond in one of 4 ways:
Select an arc
If you select an arc, DIMANGULAR dimensions the arc. The arc’s center is the vertex of the angle. You can place the dimension either inside or outside the arc.
Select a circle
If you select a circle, DIMANGULAR uses the point you picked when selecting the circle as the first angle endpoint. The circle’s center is the vertex. You are prompted for the second angle endpoint; pick a point on the circle. In this way, you are dimensioning an arc, which is just a portion of a circle.
Tip: Let’s say that you draw a circle and then draw lines that cross the circle, as you see below. If you want to select the circle and try using the Intersection object snap, you end up selecting a line, because it’s on top of the circle. That’s because newer objects are on top of older objects. If you want to selecft the circle, select it, and right-click it, and choose Draw Order> Bring to Front. Of course, you could get the same angle measurement by selecting the lines, but if you want to be dimensioning the circle (perhaps you’ll erase the lines later), bringing the circle to the front can help.
Select a line
If you select a line, DIMANGULAR’s prompt asks you for a second line. If the lines don’t intersect, the implied intersection is the vertex.
Press Enter to specify all the points of the angle
If you want to individually specify the vertex and the two angle endpoints, just press Enter. You’re then prompted for the vertex, 1st angle endpoint and 2nd angle endpoint.
Dimensioning the outside angle
In the above example, the dimension measures the minor angle, the portion that is less than 180°. By simple moving the cursor below the vertex, you can measure the major angle, as you see here.
Always use object snaps when specify the vertex and the angle endpoints. This will ensure that you get an accurate measurement.
Remember that you can specify the decimal precision of a dimension in the dimension style. For angular dimensions, start the DIMSTYLE command to open the Dimension Style dialog box. Then, on the Primary Units, tab, use the Angular Dimension section’s Precision drop-down list.
Do you have any tips for dimensions angles? Leave a comment!
When you use the displacement method of moving an object, AutoCAD remembers that displacement for the next move.
What is the displacement method? At the Specify base point or [Displacement] <Displacement>: prompt, you specify the X, Y coordinates. For example, you might type 0,4 to move the selected object up 4 units.
Want to move another object up 4 units?
Start the MOVE command and select the object. Now press Enter 3 times:
The 1st time ends selection
The 2nd time choose the displacement option at the Specify base point or [Displacement] <Displacement>: prompt.
The 3rd time moves the object the same displacement as the last time. For example, the prompt might look read Specify displacement <0.0000, 4.0000, 0.0000>:
AutoCAD moves the object up 4 units. Very simple!
And yes, you can do the same with the COPY command, but displacements that you use for MOVE aren’t saved to the COPY command and vice versa.
Arc and circle dimensions are not as common as linear dimensions (See Part I), but they are still often used. Here are the basics for getting accurate results.
Dimension a radius
To dimension the radius of a circle or an arc, follow these steps:
Go to Home tab> Annotation panel> Dimension drop-down menu> Radius. An alternative is Annotate tab> Dimensions panel> Dimension drop-down menu> Radius.
At the Select arc or circle: prompt, select an arc or circle.
At the Specify dimension line location or [Mtext/Text/Angle]: prompt, pick a location for the dimension. An R is automatically added before the dimension text.
Sometimes, when dimensioning an arc, you want to display the dimension on a part of the arc that doesn’t exist. Well, that’s easier to show than to explain. You can create an extension arc that extends past the end of an arc so you can place the dimension anywhere you want. As you place the dimension, move the cursor past the arc’s endpoint and continue to the desired point, as you see here.
Dimension a diameter
Dimensioning a diameter is just like dimensioning a radius, except that you choose Dimension from the Dimension drop-down list instead of Radius. Here are the steps:
At the Select arc or circle: prompt, select an arc or circle.
At the Specify dimension line location or [Mtext/Text/Angle]: prompt, pick where you want the dimension line to appear. A diameter symbol is automatically added before the dimension text.
Mark circle & arc centers
It’s common to mark circle and arc centers. You can use a center mark (a small cross) or centerlines. The size and type of mark are part of the dimension style. Follow these steps:
Choose Annotate tab> Dimensions panel (expanded)> Center Mark (the DIMCENTER command).
At the Select arc or circle: prompt, pick the arc or circle you want to mark.
Dimension arc lengths
To dimension the length of an arc, choose Home tab> Annotation panel> Dimension drop-down menu > Arc Length. An alternative is to choose Annotate tab > Dimensions panel > Dimension drop-down menu > Arc Length. This starts the DIMARC command. Follow these steps:
At the Select arc or polyline arc segment: prompt, select an arc.
At the Specify arc length dimension location, or [Mtext/Text/Angle/Partial/Leader]: prompt, pick to place the dimension.
An arc symbol is automatically added before the dimension text. The location of the arc symbol (above the dimension text or in front of it) is part of the dimension style. (You can squelch it altogether if you want.)
The Partial option lets you dimension part of an arc. Specify where you want to start and end the dimension. The Leader option inserts an arrow pointing to the arc.
Please leave a comment to share any tips you have for dimensioning circles and arcs.
Almost all drawings except schematics have dimensions. Obviously, the purpose of dimensions is to show accurate measurements. So what do you do to create accurate dimensions?
Create a dimension style
You should always use a customized dimension style for your dimensions. I have a tutorial, “Create an architectural dimension style,” which you’ll find useful even if you aren’t creating architectural drawings. That’s because the tutorial takes you through the entire process of creating a dimension style.
Dimensions should always be on their own layer, using a color that contrasts with the objects you are dimensioning. You don’t want your dimensions to be confused with your model! Call the layer Dimension or DIM–something like that.
Set up running object snaps
For accuracy, you should use object snaps, especially if you aren’t dimensioning an entire object. So, set up the ones you want. One way is to right-click the Object Snap (or OSNAP) button on the status bar and choose the object snaps that you want. If Object Snaps aren’t on, click the Object Snap button on the status bar.
Get set up for dimensioning
On the Home tab, in the Layers panel, choose your dimension layer from the Layer drop-down list.
Also on the Home tab, expand the Annotation panel, and choose your style from the list of dimension styles. (You can also find this list on the Annotate tab.)
Start dimensioning
Center the object that you want to dimension in the drawing area so you won’t run out of room.
Go to Home tab> Annotation panel or the Annotate tab> Dimensions panel. In either location, you’ll see the drop-down list of dimension types. For this exercise, choose Linear. This starts the DIMLINEAR command.
Follow these prompts. Specify first extension line origin or <select object>: Use an object snap to specify where you want the dimension to start. Specify second extension line origin: Use an object snap to specify where you want the dimension to end. Specify dimension line location or [Mtext/Text/Angle/Horizontal/Vertical/Rotated]: Move the cursor to where you want the dimension line to be and click.
If you are dimensioning an entire object, such as one of the vertical lines in this model, at the first prompt press Enter to select the object. This ensures an accurate result.
How do I know if I’m dimensioning the right coordinate?
When you are not dimensioning an entire object, and one of the points (the beginning or end of your linear dimension) is at the endpoint of another object, how do you ensure that you are specifying the endpoint of the object you’re dimensioning and not the endpoint of the other, touching object? For example in the model above, how do you ensure that the endpoint marked is the endpoint of the horizontal line that you want to dimension and not the endpoint of the rising line?
First, what difference does it make?
Dimensions are associative, which means that they are connected to the objects they dimension. If you edit the object, you want the dimension to adjust accordingly. But if you specify the wrong endpoint, you may not get the right result.
So when specifying an endpoint, place the cursor slightly off the endpoint of the object you are dimensioning and let the object snap specify the coordinate for you.
Watch the video to see how to place the cursor to get an accurate linear dimension.
What ideas do you have for creating accurate linear dimensions? Please leave a comment!
AutoCAD 2013 was recently released and as usual, I’m providing a summary of the major new features so you can decide if you want to upgrade.
New file format
AutoCAD is updated every year, but only every 3 years or so do they change the file format. A new file format means that people with earlier releases can’t open drawings creating in the new format. Of course, you can save drawings in an earlier format (going way back, in fact) so that others can open them.
Command line updated
The command line looks different and has several new and updated features. The most important new feature, in my opinion, is that you can click on a command’s options listed on the command line to execute them. Here are some other changes:
Recent commands list: Click the down arrow at the left side of the Command line to see a list of recent commands. You can click a command from the list to execute it.
Customize icon: Click the customize icon, also that the left side of the Command line, to configure the Autocomplete feature and also open the Options dialog box, where you can click the Colors button on the Display tab, choose Command Line from the Content box, and then specify colors for every feature of the command line.
My take: I really like the idea of being able to click options on the command line. That’s where you read through the options to see which one you need, so that’s where your attention is. It’s nice not to have to go somewhere else to choose an option.
Array enhancements
For 2012, AutoCAD introduced a new ribbon-based interface for creating arrays and also added the new path arrays. This time there are some tweaks. When you start a rectangular array, you immediately see a 3 x 4 grid; when you start a polar array, you immediately see 6 items around the center. For a path array, the objects are displayed evenly-spaced along the path. A new Measure option for path arrays automatically adds items when you lengthen the path.
Multifunctional grips let you edit properties, such as the number of rows in a rectangular array or the angle between items in the polar array. But you can still use the ribbon or command line to change properties.
My take: I’m neutral on these changes.
Dynamic preview of changes
When you select an object and hover over an item that will change the way it looks, you see that change before clicking. For example, if you select a black circle, and hover over a layer in your layer drop-down that is red, you’ll see a red circle. This is true whether that layer drop-down is on the ribbon, the Properties palette, or the Quick Properties palette. You can also preview changes to viewports, visual styles, and more.
If you don’t want this feature, you can turn it off. In the Options dialog box (OPTIONS command), click the Selection tab and uncheck the Property Preview checkbox.
My take: A great feature and long overdue. After all, Microsoft Office has had this feature since Office 2007! You’ll quickly get so used to it that you won’t even realize it’s a new feature.
OFFSET preview
When you use the OFFSET command, you see a preview before you commit to the exact location.
My take: Another nice feature.
Point Cloud improvements
The Insert tab has a new Point Cloud panel when you’re in the 3D Modeling workspace. You can attach and manage point cloud files similar to the way you work with xrefs. The Properties palette provides more info about point clouds and there’s a new Point Cloud Intensity tool. You can index scanned files from major industrial scanner companies, such as Leica, Topcon, and Faro.
My take: I’ve never used point clouds, except to test them. Do you use point clouds? Is this update important to you? Leave a comment!
VIEWBASE (2D view object) improvements
AutoCAD 2012 introduced the VIEWBASE command to create 2D view objects. (I have a tip on this command here.) 2D view objects lets you show 2D views of your 3D models in a viewport.
AutoCAD 2013 updates view objects significantly:
You can select which objects to include.
You can add labels and styles. The new Section View Style Manager lets you customize how your 2D view objects look.
You can create sections.
You can use multifunctional grips to modify the section view, move the section line, add and remove vertices, flip direction, reposition identifiers, and more.
You can create details from existing views.
You can add associated annotations, e.g. dimensions and multileaders.
The new Auto Update tool lets you automatically update 2D view objects when your model changes.
My take: I like 2D view objects and the updates are good additions.
PRESSPULL improved
The PRESSPULL command is more flexible and context sensitive. You can use it to select and extrude 2D and 3D curves, creating surfaces and solids. There’s a new Multiple option so you can select multiple objects, or can you press Shift key to select additional objects. The command now prompts for an extrusion height or offset distance immediately after selection.
My take: These new PRESSPULL features will make the command easier and more useful. It was sometimes a little hard to use before.
Online enhancements
If you haven’t heard of computing in the cloud, where have you been? (Hint: It has nothing to do with point clouds!)
For AutoCAD 2012, Autodesk introduced AutoCAD WS, Now, there’s Autodesk Cloud which gives you online storage–3 GB. Start the OPTIONS command and click the Online tab to set up this storage. And there are new smart phone apps for AutoCAD WS.
AutoCAD 360 lets you sync drawings. Go to the Online tab of the ribbon and click Autodesk 360 to go to the site in your browser. AutoCAD 360 actually lets you do some editing in your browser. Of course, you can also just view drawings there. In fact, you can even render in AutoCAD 360, while you continue to work locally.
My take: I admit that I’m confused with all the names–WS, Cloud, and 360. But then, Autodesk has a long history of changing the names of its products and services. But cloud computing is the wave of the future. Especially if you work in the field or travel, you’ll find these features useful. And everyone collaborates, so what’s not to like?
Have you upgraded? Are you planning to? What is your favorite new feature? Leave a comment!
Important: While we don't collect cookies, some of our 3rd-party services (such as PayPal and WordPress) do, to give you a safer and better browsing experience. Read about how we use cookies and keep your personal information secure by reading our Privacy Policy here.