CHAPTER 12
Keeping In Control with Constraints

Constraints are specific restrictions applied to objects that allow for design exploration while maintaining object shape and/or size within predefined limits. In this chapter, you will create three types of constraints in the AutoCAD® 2016 program: geometric, dimensional, and user-created. Once the design has been sufficiently constrained, you will make a host of geometric and dimensional changes simply by changing a single parameter.

In this chapter, you’ll learn to do the following:

  • Work with geometric constraints
  • Apply dimensional constraints
  • Constrain objects simultaneously with geometry and dimensions
  • Make parametric changes to constrained objects

Work with Geometric Constraints

Geometric constraints allow you to force specific 2D objects to be coincident, collinear, concentric, parallel, perpendicular, horizontal, vertical, tangent, smooth, and symmetric; to have equal lengths; or to be fixed in world space. In the following exercise, you will assign sufficient geometric constraints to ensure that a rectangle will always remain square even when it is stretched.

Exercise 12.1: Use Geometric Constraints

Begin by opening the file Ex12.1-start.dwg, which is among the companion files available for download from this book’s web page, www.sybex.com/go/autocad2016essentials.

images

  1. Select the Rectangle tool on the Draw panel. Click two points on the drawing canvas to create an arbitrarily sized rectangle.
  2. Type CONSTRAINTINFER and press Enter. Type 1 (to turn this mode on) and press Enter.
  3. Type REC (for Rectangle) and press Enter. Click two more points to draw another arbitrarily sized rectangle adjacent and to the right of the first one (see Figure 12.1). AutoCAD automatically infers perpendicular and parallel constraints from the geometry of the second rectangle.

    images

    Figure 12.1 Drawing two rectangles, one unconstrained

  4. Toggle off Infer Constraints mode by pressing Ctrl+Shift+I.
  5. Select both rectangles with a crossing selection window. Hover the cursor over the upper-right grip of the left rectangle, select Stretch Vertex from the grip menu that appears, and stretch it up and to the right so that the rectangle deforms. Hover the cursor over the upper-right grip of the right rectangle, select Stretch Vertex from the grip menu, stretch it up and to the right, and click to set its new location. The rectangle remains a rectangle because of the constraints (see Figure 12.2). Press Esc to deselect.

    images

    Figure 12.2 Stretching constrained geometry limits the types of transformation that can occur.

    images

  6. Select the Parametric tab on the ribbon and select the Auto Constrain tool in the Geometric panel. Select the unconstrained rectangle on the left and press Enter. Two constraints are applied: perpendicular and horizontal (see Figure 12.3).

    images

    Figure 12.3 Applying constraints with the Auto Constrain tool

    images

  7. Select the Parallel constraint tool in the Geometric panel. Click lines A and B shown in Figure 12.3. Line B is automatically repositioned to conform to the parallel constraint applied to line A.

  8. Press the spacebar to repeat the GCPARALLEL (for Geometric Constraint Parallel) command. Click lines C and D shown in Figure 12.3.
  9. Not only does the left rectangle have parallel and perpendicular constraints like the right rectangle, but it also has a horizontal constraint that was applied by the Auto Constrain tool. Select the right rectangle and press the Delete key.

    images

  10. Select the Equal constraint tool in the Geometric panel. Click lines A and C in Figure 12.3. The rectangle becomes a square (see Figure 12.4).
    images

    Figure 12.4 Applying Equal constraints to adjacent sides turns the rectangle into a square.

  11. Multiple constraints are grouped together in what is called a constraint bar. Position the cursor over the constraint bar, and you’ll see a tiny Close box. Click it to hide the constraint bar.

    images

  12. Click the Show All button in the Geometric panel. The hidden constraint bar reappears.
  13. Right-click the horizontal constraint and choose Delete from the context menu. The rectangle is no longer constrained horizontally (so you could rotate it if desired).

    images

  14. Click the Hide All button in the Geometric panel. The constraints are hidden but still active.

Your model should now resemble Ex12.1-end.dwg, which is available among this chapter’s companion files.

Apply Dimensional Constraints

Dimensional constraints allow you to control object sizes with specific numerical values and to set up dynamic dimensional relationships with mathematical equations and formulas. User constraints are not tied to specific geometry but hold values calculated from dimensional constraints. In the following exercise, you will create dimensional constraints.

Exercise 12.2: Create Dimensional Constraints

To begin, open the file Ex12.2-start.dwg from this chapter’s companion files.

images

  1. Select the ribbon’s Home tab, open the Layer drop-down menu in the Layers panel, and select Layer 2 to make it the current layer.

    images

  2. Select the Parametric tab on the ribbon. Select the Linear constraint tool in the Dimensional panel, and click constraint points A and B, shown in Figure 12.5. Constraint points highlight in red onscreen when you move the cursor near them. Click point C to locate the dimension line. Press Enter to accept the default dimension text. This dimensional constraint is automatically given the variable name d1.

    images

    Figure 12.5 Creating a vertical linear dimensional constraint

  3. Type C (for Circle) and press Enter. Draw an arbitrarily sized circle anywhere within the square.

    images

  4. Click the Linear constraint tool in the Dimensional panel, and click the first constraint point in the upper-left corner of the rectangle. Click the circle to accept its center as the second constraint point. Move the cursor upward and click to place the horizontal dimension line above the rectangle (see Figure 12.6). Move on to step 5 without pressing Enter.
    images

    Figure 12.6 Creating a horizontal linear dimensional constraint

  5. Type d2=d1 and press Enter. The circle moves over so that it is horizontally centered within the rectangle and the constraint reads fx:d2=d1. The fx means the dimensional constraint is calculated by a function.
  6. Press the spacebar to repeat the DCLINEAR (for Dimensional Constraint Linear) command. Click the first constraint point in the upper-right corner of the rectangle. Click the circle to accept its center as the second constraint point. Move the cursor to the right and click to place the vertical dimension line to the right of the rectangle. Type d3=d1 and press Enter. The circle is now centered within the square (see Figure 12.7).

    images

    Figure 12.7 Adding another linear constraint that is calculated by a function

    images

  7. Click the Parameters Manager button in the Manage panel to open the Parameters Manager. All the dimensional constraints that you have created are listed here (d1, d2, and d3). Click the ƒx button to create a new user parameter.
  8. Type P (for Perimeter) as the user parameter name and press Enter. Double-click the Expression value, type d1*8 (d1 times 8), and press Enter (see Figure 12.8). The perimeter of the square is equal to eight times the length of half of one of its sides. Close the Parameters Manager.

    images

    Figure 12.8 Adding a user parameter in the Parameters Manager

    images

  9. Select the Hide All button in the Dimensional panel.

    images

  10. Select the Diameter constraint tool in the Dimensional panel, select the circle, click a point inside the circle to locate the dimension line, type dia=P/PI, and press Enter. The variable PI is hard-coded as 3.14159265; there is no need to define it as a user variable. The circumference of the circle is now equal to the perimeter of the square, traditionally called squaring the circle (see Figure 12.9).
images

Figure 12.9 Squaring the circle with constraints defined by formulas

Your model should now resemble Ex12.2-end.dwg, which is available among this chapter’s companion files.

Constrain Objects Simultaneously with Geometry and Dimensions

You can use geometric and dimensional constraints together to force objects to conform to your design intent. In the following exercise, you will draw two more circles and constrain their positions and sizes using a combination of geometric and dimensional constraints.

Exercise 12.3: Use Simultaneous Constraints

To begin, open the file Ex12.3-start.dwg.

images

  1. Select the ribbon’s Home tab, open the Layer drop-down menu in the Layers panel, and select Layer 3 to make it the current layer.
  2. Type C (for Circle) and press Enter. Draw an arbitrarily sized circle anywhere within the square.

    images

  3. Select the ribbon’s Parametric tab and then click the Concentric constraint tool in the Geometric panel. Select the green circle and then the yellow circle. The yellow circle immediately moves to conform to the geometric constraint so that it is concentric within the larger circle.

    images

  4. Select the Radius constraint tool in the Dimensional panel, select the yellow circle, and click a point inside the circle to locate the dimension line. Type rad=d1 and press Enter. The yellow circle changes size so that it fits perfectly within the square (see Figure 12.10).

    images

    Figure 12.10 Constraining the yellow circle geometrically and dimensionally

    images

  5. Select the Hide All button in the Dimensional panel.

    images

  6. Select the ribbon’s Home tab, open the Layer drop-down menu in the Layers panel, and select Layer 4 to make it the current layer.
  7. Type C (for Circle) and press Enter. Draw an arbitrarily sized circle anywhere above the square.

    images

  8. Select the ribbon’s Parametric tab and click the Tangent constraint tool in the Geometric panel. Select the top line of the square as the first object and the magenta circle as the second object. The circle moves down to conform to the tangent constraint (see Figure 12.11).
    images

    Figure 12.11 Applying a tangent geometric constraint

  9. Press the spacebar to repeat the GCTANGENT (for Geometric Constraint Tangent) command. Select the yellow circle first and then select the magenta circle. The magenta circle moves on top of the yellow circle to conform to the new tangent constraint.

    images

  10. Click the Linear constraint tool in the Dimensional panel. Click the magenta circle, the yellow circle, and then a point off to the right to place the dimension line. Type d4=dia/2 and press Enter (see Figure 12.12). The center of the magenta circle is anchored effectively at the top quadrant (or top cardinal point) of the green circle.

    images

    Figure 12.12 Adding the last dimensional constraint

    images

    images

  11. Click the Hide All button in the Dimensional panel, and click the Hide All button in the Geometric panel.

Your model should now resemble Ex12.3-end.dwg, which is available among this chapter’s companion files.

Make Parametric Changes to Constrained Objects

Once you have intelligently applied geometric and/or dimensional constraints, it is easy to make parametric changes that affect the shape and/or size of multiple interconnected objects. In the following exercise, you will change a single parameter (d1) and see how it affects the objects you have constrained. In addition, you will add dimensions to two circles and uncover an amazing coincidence.

Exercise 12.4: Alter Constraint Parameters

To begin, open the file Ex12.4-start.dwg.

images

  1. Select the ribbon’s Parametric tab and click the Parameters Manager button in the Manage panel.
  2. Double-click the d1 parameter’s expression. Type 3 and press Enter. All parameter values are recalculated because they are all based on the first parameter you created earlier in this chapter (see Figure 12.13).

    images

    Figure 12.13 Changing a single parameter has a cascading effect.

    images

  3. Click the Zoom Extents tool in the Navigation bar. The form of the diagram remains unchanged; only the scale has changed.
  4. The Earth’s polar radius is 3949.9 miles (or 6356.8 km). Double-click the d1 parameter’s expression. Type 3949.9 (or 6356.8 in metric) and press Enter. Close the Parameters Manager.

    images

  5. Click the Zoom Extents tool in the Navigation bar.

    images

  6. Select the ribbon’s Home tab, open the Layer drop-down menu in the Layers panel, and select 0 to make it the current layer.

    images

  7. Select the ribbon’s Annotate tab, open the Dimension menu in the Dimensions panel, and click the Radius tool. Select the yellow circle and then click a point inside the circle to locate the dimension object.
  8. Press the spacebar to repeat the DIMRADIUS (Dimension Radius) command. Select the magenta circle and click a point outside the circle to locate the dimension object. Figure 12.14 shows the result.
images

Figure 12.14 Dimensioning two radii in the squaring the circle diagram

Your model should now resemble Ex12.4-end.dwg, which is available among this chapter’s companion files.

The Moon’s polar radius is 1078.7 miles (or 1735.97 km). The diagram encodes the actual sizes of Earth and Moon with 99.9 percent accuracy.