You can precisely position constraints in one of the following ways.
• Using Object Snap, you can automatically attach a constraint at a precise location when you create it.
• Using Grid Snap, you can create a constraint so that it is automatically aligned to the background grid.
• Using the Coordinates bar, you can quickly view and modify the geometry of constraints numerically.
• Using the Properties window, you can directly edit the endpoint coordinates numerically.
When you are editing the constraint coordinates numerically, you can use not only numeric values but also geometry-based formulas which specify constraint positions with respect to the geometry of bodies.
Using Object Snap When Object Snap is active, an endpoint of a constraint automatically attaches to the closest snap point of a body or to the closest point element when you release the mouse button. The attachment occurs only if the snap symbol (marked as an X) appears (see below). This Object Snap feature helps you position the constraints precisely right from the start. For example, you can easily position a motor to the geometric center of a circle.
As the mouse pointer hovers across the screen, the closest snap point is shown with an X-shaped symbol. Figure 4-10 is an example where a motor is about to be attached to the center of a circle.
Figure 4-10
Attaching a motor with Object Snap
Only by dragging the motor near the midpoint... the motor attaches to it automatically.
The object snap feature can be turned on or off at any time. To toggle the object snap mode:
1. Choose Object Snap in the View menu.
Object Snap is already active if a checkmark is visible beside the menu item.
Each type of body has a specific set of snap points shown in Figure 4-11. Curved bodies have only one snap point, at the frame of reference (FOR). To use snap points at control points and/or the midpoints between them, convert the curved body into a polygon, attach a constraint, and then convert back into a curved body (see “Converting Between Polygons and Curved Bodies” on page 80).
Figure 4-11
Snap Points for bodies
When a constraint is attached to a snap point on a body, Working Model 2D automatically generates the geometry-based formula to define the endpoint coordinates. See “Using Geometry-based Formulas (Point-based
Parametrics)” on page 104 for information on this feature.
You can disable this automatic formula generation through the Preferences dialog. When formula generation is disabled, Object Snap will still be active, but the coordinates of the attachment points will be given with numeric values rather than geometry-based formulas. See “8.4. Preferences” for more information. 1 2 ---h 1 2 ---h 1 2 ---h Rectangle / Square Circle Polygon
Corners, FOR, Midpoints Two Extra Points (shown below) FOR, Quadrants
FOR, Vertices, Midpoints
Using Grid Snap When the Grid Snap feature is active, you can attach a constraint endpoint to the background so that it is automatically aligned to the regular intervals of the grid. You can also align bodies with the Grid Snap.
To activate Grid Snap:
1. Choose Grid Snap in the View menu.
Grid Snap is already active if a checkmark is visible beside the menu item.
Please see “Aligning Objects to the Grid” on page 200 for more information.
Using the Coordinates Bar The Coordinates bar (Figure 4-12) displays constraint parameters that are frequently edited, such as the endpoint coordinates.
For rotational constraints, the first set of (x, y) values holds the coordinates of the Base Point (point element attached to the body in the lower layer; see Figure 4-12). The values are given in terms of the local coordinate system. For linear constraints, the first set of (x, y) values holds the coordinates of the first point created (see Figure 4-12).
Figure 4-12
Coordinates bar
Furthermore, if you select an individual endpoint, the Coordinates bar displays the values in local and global coordinates. The local coordinates are shown with (x, y) labels, whereas the global coordinates are shown with (Gx, Gy) labels.
6.0 4.0 (1.0, 0.0)
Base Point (on the background) is at (6.0, 4.0). Top Point (on the disk) is at (1.0, 0.0). For Rotational Constraints...
For Linear Constraints...
Base Point Top Point
x y
2.0 1.0
(-1.0, 0.0) Suppose that the Spring is drawn from the bodyto the background. Then the first point is at (-1.0, 0.0). The second point is at (2.0, 1.0).
Figure 4-13
Local and global coordinates for a point element
NOTE: If the position of the endpoint is defined by a formula (see “Using Geometry-based Formulas (Point-based Parametrics)” on page 104), its global coordinates are not available in the Coordinates bar.
You can enter numerical values or formulas in the Coordinates bar. The modification takes effect immediately even if formulas are entered. Individual sections later in this chapter discuss which parameters can be edited using the Coordinates bar for each constraint.
Using Geometry-based Formulas (Point-based Parametrics)
Working Model 2D features geometry and constraint-based parametrics. You can use these formulas to define positions of objects via symbols rather than numerical values. For example, Figure 4-14 shows how point positions on rectangles and a circle can be expressed using parametric formulas.
Figure 4-14
Examples of geometry formulas
When the coordinates are given with geometry-based expressions (such as ((0.0), (0.0)) and body[3].width), global coordinates are not available for editing.
Local Coordinates Global Coordinates
Local Coordinates (0.0, body[3].radius / 2) (body[2].width / 4, 0.0) (body[2].width / 2, body[2].height / 2) (body[1].width / 2, -body[1].height / 2) body[1] body[2] body[3] attached to body[1] attached to body[2] body[2].width body[3].radius body[2].height
To modify the position of constraint endpoints via parametric formula:
1. Select the constraint endpoint whose position you would like to modify. 2. Choose Properties in the Window menu.
Properties window appears.
3. Type the desired geometry-based formula in the position fields.
Alternatively, you could type the formulas directly into the Coordinates bar; however, you may find the fields a bit too short to enter long expressions.
Geometry formulas not only help you position constraints endpoints precisely, but also make these endpoint attachment immune to resize and reshape. As shown in Figure 4-15, you can stretch a rectangle, and the spring endpoint stays attached to the midpoint of one of its sides.
Figure 4-15
How geometry formulas preserve constraint attachment
Please refer to Appendix B, “Formula Language Reference” for a complete listing of formula language expressions.