grasshopper2 Rhinorhino3d.com
TopicConstraints
Constraint Rules

This topic is a reference for all the constraint rules available in the Grasshopper constraint editor; which shapes they can be applied to, what they enforce, and any peculiarities worth knowing about.

Constraints come in two categories; dimensional and relational. Dimensional constraints hold measurements, such as Length, Distance and Angle. Relational constraints meanwhile define interactions between shapes, such as Perpendicular, Tangent or Concentric.

For an overview of constraints and how they are implemented in Grasshopper, see the Constraint Systems topic.

Applying Constraints

Constraints are applied by selecting the shapes they should act on, and then clicking a button in the side panel of the editor or pressing its shortcut key. Note that new shortcuts can be assigned to all tools by right-clicking on the button and typing the new shortcut. Buttons are greyed out while the selection does not allow the constraint.

Figure 1. The constraint buttons on the editor, grouped by category.
Figure 1. The constraint buttons on the editor, grouped by category.

Every constraint is shown as a small tag next to or between the shapes it acts on. Dimensional tags show their value while relational tags show a symbol, as per figure 2.

Valid tags are drawn in black, redundant tags in cyan, conflicting tags in red and selected or hovered tags in yellow. See the Degrees of Freedom topic for more information on conflicting and redundant constraints.

Figure 2. A mixture of relational and dimensional constraint tags in the editor.
Figure 2. A mixture of relational and dimensional constraint tags in the editor.

When a dimensional constraint is added to the drawing, it is always given the current value. This way the system does not need to update to incorporate the new dimension. That does mean the initial value is often a very messy number, which may not be reflected in the drawn tag due to the aggressive rounding. A new distance constraint between points which are 4.00139572 units apart will nevertheless appear as 4.00 in the editor, since only two decimal places are drawn inside the tags. Always double-click dimensional tags to validate and change the values those constraints are actually supposed to enforce.

Constraint Overview

Table A below lists all the available constraints, along with the object or objects they apply to and the degrees of freedom they remove from the system. When a constraint can apply to different sets of objects, it will be listed more than once.

Constraint Application ΔDoF
Angle Single line or guide −1
Angle Pair of lines −1
Angle Line and a guide −1
Coincident Pair of points −2
Coincident Point and a curve or guide −1
Concentric Pair of non-linear curves −2
Concentric Point and a non-linear curve −2
Distance Pair of points −1
Equal Pair of curves −1
Equal Set of n curves −(n−1)
Fix Single point −2
Fix Single guide −1
Height Single line, or a pair of points −1
Horizontal Single line, or a pair of points −1
Length Single curve −1
Midpoint Point and a line, arc or bend −2
Parallel Pair of lines, or a line and a guide −1
Perpendicular Pair of lines, or a line and a guide −1
Radius Single circle, arc or bend −1
Sweep Arc or bend −1
Tangent Pair of curves −1
Tangent Point where two curves meet −1
Vertical Single line, or a pair of points −1
Width Single line, or a pair of points −1
Table A. All available constraints.

The remainder of this topic provides additional details for each type of constraint.

Dimensional Constraints

Horizontal and Vertical

Figure 3. Three sides of a rectangle constrained to cardinal directions, with the naked end points also constrained vertically.
Figure 3. Three sides of a rectangle constrained to cardinal directions, with the naked end points also constrained vertically.

Strictly speaking these are not dimensional constraints, as they have no value which can be set. However, they live in the dimensional category because they are special cases of the Height and Width constraints.

The Horizontal and Vertical constraints can be applied to a line, or to a pair of points, even if those points are otherwise unconnected. Holding Shift while drawing a new line automatically assign a Horizontal or Vertical constraint to that line.

Width and Height

Figure 4. Width and height of two connected line segments are kept constant. Their lengths are allowed to change.
Figure 4. Width and height of two connected line segments are kept constant. Their lengths are allowed to change.

Width and Height hold the horizontal or vertical distance between two points, or between the two ends of a line. Unlike Distance, these dimensions exhibit directionality; a width of 10.0 means the second point lies 10.0 units to the right of the first, and a width of −10.0 means it lies 10.0 units to the left. When the dimension is first added, the points are ordered so that the initial dimension value is positive.

Distance and Length

Figure 5. Maintain distance between points and maintain the length of links in a chain.
Figure 5. Maintain distance between points and maintain the length of links in a chain.

When applied to a pair of points, the Distance constraint maintains the Euclidean separation between them. When applied to a single curve, the Length constraint maintains the length of the target curve.

Radius

Figure 6. Maintain the radii of a chain of tangent circles.
Figure 6. Maintain the radii of a chain of tangent circles.

When applied to a circle, arc or bend, maintains the radius of that curve. The Radius constraint is not available for a bend without a bulge, as it would result in an infinite radius constraint.

Sweep

Figure 7. A series of tangent bends with ever increasing sweep angles.
Figure 7. A series of tangent bends with ever increasing sweep angles.

Sweep holds the angle covered by an arc or a bend, in degrees. Arcs always run anticlockwise, so their sweep is between 0° and 360°. A bend with a given sweep may bulge to either side, so a sweep constraint does not stop a bend from flipping.

Note that bends are not able to form into complete circles, so sweep angles very near 360° will not work. Conversely, linear bends all have a sweep angle of 0°, which may also cause problems in the stability of the constraint system.

Angle

Figure 8. An angled line and a tangent circle whose circumference equals the length of the line.
Figure 8. An angled line and a tangent circle whose circumference equals the length of the line.

Applied to a single line or guide, Angle holds the direction of that line relative to the horizontal axis of the drawing, measured anticlockwise and ranging from −180° to 180°.

Figure 9. A rectangle oriented at a 175° angle to a fixed, tilted guide.
Figure 9. A rectangle oriented at a 175° angle to a fixed, tilted guide.

When applied to two lines, or to a line and a guide, Angle holds the angle between them. The angle is measured anticlockwise from the direction of the first line to the direction of the second, where the direction of a line runs from its start to its end. When the dimension is first added, the lines are ordered so that the initial angle value is positive.

Fix

The Fix constraint anchors points and guides at their current locations. The solver never moves a fixed point, though they can still be dragged by hand or driven by component inputs. Clicking Fix while all selected points are already fixed releases them again. The origin is inherently fixed and cannot be released.

Naming fixed points is one of the major ways in which Grasshopper can interact with a constraint system. Double-click fixed points to give them a unique name, and that name appears as an input to the component. That input accepts a variety of data types, and the values provided are used to set the location of the fixed point.

Type Usage
Point2 Two-dimensional points specify the location of the fixed points in drawing plane coordinates.
Point3 Three-dimensional points specify the location of the fixed points in world coordinates, which are then projected back onto the drawing plane.
Curve Curves specify the location of the fixed points at their intersection with the drawing plane.

Fixing a guide pins it at its current position, by adding an intercept dimension. This holds where the guide crosses the x-axis for vertical guides, or the y-axis for horizontal guides. Unlike a distance, an intercept constraint can be negative.

Relational Constraints

Coincident

Applied to two points, Coincident forces them to occupy the same coordinates. The Simplify option in the gear menu can be used to actually merge coincident points into a single entity, which makes mouse picks a lot less annoying.

Figure 10. Five points are coincident with a line whose end points are fixed.
Figure 10. Five points are coincident with a line whose end points are fixed.

When applied to a point and a curve or guide, Coincident forces the point onto that curve. Though note that coincidence is considered only on the infinitely extended version of each curve. Line coincidence projects onto the infinite line, not the finite segments between the end points. Arc coincidence projects onto the full circle, not the partial arc.

Concentric

Concentric gives two circles, arcs or bends the same centre. This is very similar to the Coincident constraint, except that bends don't have points at their centres.

Figure 11. A circle kept concentric with a fillet arc.
Figure 11. A circle kept concentric with a fillet arc.

When applied to a point and a non-linear curve, it creates a coincidence requirement between the point and the centre of the curve.

Concentric constraints involving bends should be used with care. The centre of a bend moves further and further away as the bend straightens, and two straight bends are considered concentric no matter where they are. If a bend needs a well-behaved centre, an arc is probably the better choice.

Midpoint

Figure 12. An arc whose centre lies on the midpoint of a line, and a circle whose centre lies on the midpoint of the arc.
Figure 12. An arc whose centre lies on the midpoint of a line, and a circle whose centre lies on the midpoint of the arc.

Midpoint holds a point exactly halfway along a line, arc or bend, measured along the curve. Note that circles cannot participate in midpoint constraints as they have no start or end.

Parallel and Perpendicular

Figure 13. Free lines being kept parallel and perpendicular to a fully constrained line.
Figure 13. Free lines being kept parallel and perpendicular to a fully constrained line.

Parallel holds two lines at the same angle, while Perpendicular holds them at right angles. Lines are parallel whether they run the same way or opposite ways. A guide can stand in for one of the two lines, but not for both.

Tangent

Figure 14. A collection of circles with a lot of tangency constraints.
Figure 14. A collection of circles with a lot of tangency constraints.

The Tangent constraint works in two different ways, depending on whether the curves share an end point. When two lines, arcs or bends meet at a shared end point, Tangent removes the kink at that point, so one curve flows smoothly into the next. Instead of selecting both curves, it is also possible to assign the tangency constraint to the point where they meet.

When the curves do not share an end point, Tangent makes them touch somewhere along their length. At least one of them has to be a circle, arc or bend, and a guide can stand in for a line. A circle can touch another circle on the inside or on the outside, and the solver keeps whichever of the two is closest to the current configuration.

As with Coincident, tangency considers the complete line or circle, so an arc may end up touching a line at a spot which the arc itself does not cover.

Equal

Figure 15. A bunch of curves with equal length constraints.
Figure 15. A bunch of curves with equal length constraints.

Equal applies to two or more curves at once. When all selected curves are circles, arcs or bends, Equal holds their radii equal. When at least one of them is a line, it holds their lengths equal instead. Selecting curves which are already part of an equal group adds the new curves to that group.

Double-clicking the tag of an Equal constraint allows typing a linear relation instead of simple equality. Typing *1.5 +2 makes the length or radius of the tagged curve one-and-a-half times that of its partner, plus two units. Typing = turns it back into plain equality.

Figure 16. A length relation between three parallel lines. The topmost line is always half the length of the middle one, and the bottommost line is one quarter unit shorter than the middle one.
Figure 16. A length relation between three parallel lines. The topmost line is always half the length of the middle one, and the bottommost line is one quarter unit shorter than the middle one.