Defining and Constraining Sketches
The estimated time of completion is 10 minutes
Onshape provides automatic inferencing to automatically apply constraints to your sketch. Use dimension and manually applied constraints to help fully define a sketch in order to maintain design integrity.
When you hover over a title in the documents list, an underline appears indicating that you can click to open that document. If you click in the row without the underline appearing, you simply select that row of the table.
You created the document named Primer in the previous lesson Creating Parts. Navigate to the Documents page (after signing in to your Onshape account):
- For enterprise users, click Documents at the top of the page. Everyone else lands on the Documents page upon sign in.
- Click the My Onshape filter on the left to display your most recently opened documents.
- Click the title of the document named Primer.
The document opens to the last active tab.
- If Part Studio 1 is not open, select it now.
- As you sketch with a sketch tool, move the mouse over other sketch entities to wake up automatic inferencing.
- You can drag all dialog boxes around the space for better viewing.
- Some basic automatic inferences that appear while you are sketching include: vertical, horizontal, coincident, parallel, midpoint, and perpendicular. Inferencing is indicated by dashed yellow lines.
- To suppress automatic inferences when sketching, press the Shift key when mousing. Holding the Shift key when mousing during sketching prevents any automatic constraints from being applied.
- Show all constraints by selecting the Show constraints checkbox.
- Show one sketch entity's constraints by hovering over that entity. Use the Shift key to keep the constraints visible in order to select one.
- Select a constraint or even just hover over one to see what sketch entities are constrained by it (highlighted in orange).
To include design integrity immediately in your design, you can use Onshape's automatic inferencing while sketching and apply additional constraints after sketching. Automatic inferencing is the ability to move near another entity to 'wake up' inferencing and apply constraints automatically.
To practice using automatic inferencing while sketching:
- Click Sketch to select the Sketch tool in the toolbar.
- Select a plane. (Press the 'N' key to orient the plane normal to your view.)
- Click in the toolbar to select the Circle tool.
- Click in the graphics area to set the center of the circle.
- Move the cursor away from the first point and click again to set the diameter of the circle.
Now sketch another circle, using the first circle to wake-up inferencing and constrain the circles to each other:
- With the Circle tool still selected, move the cursor towards the center of the circle just sketched.
- Notice that the center of the circle is highlighted in orange and a small box appears around it.
- Move your cursor horizontally away from the center and notice a dashed orange line that follows the cursor along with a small white box with a horizontal line in it (the horizontal constraint icon):
- Click to set the center of the second circle when the horizontal line is visible, and you set a horizontal constraint between the two circles.
- Click to set the diameter of the second circle.
- Press Escape to deactivate the Circle tool.
Now test the constraint:
- Click either circle's perimeter and drag. The circle resizes.
- Click a circle centerpoint and drag. Notice that the circle will move in a horizontal direction, aligned horizontally with the other circle. Move the circle vertically and the other circle moves with it (barring no other constraints on either circle).
- To view all of the constraints, mark the Show constraints check box in the Sketch dialog.
View sketch constraints
Constraint icons are generally either blue or white. Blue indicates a constraint associated with something outside of the sketch, for instance the origin, or an edge of a previous feature.
White indicates a constraint between entities in that sketch.
Onshape makes it easy to not only to see all the constraints, but also to evaluate them.
Once you check Show constraints, you have options for viewing and evaluating:
- If it is difficult to see all the constraints, click and drag constraint icons to new locations for easier viewing. This does not change them in any way.
- Select a constraint and the associated sketch entities are highlighted as well, so you can see the entities bound by the constraint:
When you select or hover over a constraint, the sketch entities involved in it are highlighted in yellow, and the entities bound by the constraint are highlighted in orange:
To delete a constraint or dimension, or anything else in the graphics area, click to select it and press the Delete key.
The best workflow for sketching always includes fully-defining the sketch so that altering one part of it does not alter the intent of the design. Defining a sketch includes using dimensions and constraints.
To identify which entities in your sketch are not fully-defined, look at the color of the curves:
- Blue indicates not fully-defined; you can drag to move the entity or change its size
- Black indicates fully-defined; you cannot drag to move or alter the entity
- Red indicates over-defined, an error, and sometimes an unresolvable sketch
You can also check for constraints, as described above. When there are problems with constraints they are displayed in red:
If we apply a dimension between the two circles you've sketched, the sketch becomes more defined:
- First, click and drag one of the circle's center to be coincident with the origin. Just drag the center to the origin and let go of the mouse button when you see a yellow box around the origin.
- Now, use the 'D' key to activate the Dimension tool (or click it in the toolbar).
- Click the center of the larger circle, and then click the center of the smaller circle.
- Move the cursor to a convenient spot to display the dimension and click to set it there.
- Type "3.5 inches" and press Enter.
- With the Dimension tool still active, click the edge of the large circle and move the cursor away, click to set the location of the diameter dimension text and type "3 inches". Press Enter.
- Click the edge of the small circle and move the cursor away, click to set the location of the diameter dimension text and type "2 inches". Press Enter.
- Press Escape to exit the Dimension tool.
Notice that both circles are now black and cannot be moved or resized.
- Click to accept the changes.
To edit a sketch, it's dimensions or constraints, double-click the sketch name in the Features list to open the sketch dialog for editing. Delete a constraint or a dimension by selecting it and pressing the Delete key.
The Coincident constraint can also be used to make lines colinear (a separate operation in other CAD systems)
For more information about Onshape constraints, see the Help section listed below:
Coincident - Make two or more entities coincident, including a sketch entity and a plane.
Concentric - Make any point coincident with the center of an arc or circle. Also make arcs and circles share a center point.
Parallel - Make two or more lines parallel.
Tangent - Form a tangent relation between two curves, or between a curve and a plane.
Horizontal - Make one or more lines, or sets of points, align horizontally relative to the current sketch plane.
Vertical - Make one or more lines, or sets of points, align vertically.
Perpendicular - Form a right angle between two lines.
Equal - Make two or more sketch curves of the same type equal in size.
Midpoint - Constrain a point to the midpoint of a line or arc.
Normal - Make a line and curve, or a curve and a plane normal to each other.
Pierce - Constrain a sketch entity (point or curve) to be coincident with the intersection point of its sketch plane and an arbitrary curve that is not in its sketch plane. The sketch entity is now constrained to be coincident with the point of intersection.
Symmetric - Constrain two geometries (of the same type) to be symmetric relative to a line.
Fix - Ground a sketch entity on the sketch plane so that it does not move.
Curvature - Create curvature continuous transitions between sketch splines (and conics) and surrounding geometry.