Sketcher

You might also like

You are on page 1of 88

A Sketcher Lecture

Christoph Blaue

with special thanks to members of the FreeCAD forum:

bejant, TheMarkster, openBrain, MSOlsen65

April 8, 2021
Contents

I Basics 6

1 Create a sketch 6
1.1 Create Sketch from Sketcher workbench . . . . . . . . . . . . . . . . . . . . . 6
1.2 Create Sketch from PartDesign workbench . . . . . . . . . . . . . . . . . . . 7

2 The Sketcher Window 9

3 General Remarks on Degrees of Freedom 11

4 Auto Constraints 14
4.1 Auto Constraints On . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.2 Auto Constraints Off . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

II Geometric Elements 18

5 Common Usage 18

6 Line 19

7 Circle 22

8 Arc 27

9 Polyline 29

10 Rectangle 31

11 Polygon 32

12 Slot 33

13 B-splines 36

14 Conical sections 41
14.1 Creating and using conical sections . . . . . . . . . . . . . . . . . . . . . . . 41
14.2 Tangency and perpendicular on conical sections . . . . . . . . . . . . . . . . 42

15 Construction Geometry 42

2
16 Point 44

III Constraints 45

17 Selecting Constraints 45

18 Applying constraints 46

19 The Solver 46
19.1 Solving a Sketch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
19.2 Flipping Sketch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
19.3 Solver Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
19.3.1 Messages you want to see . . . . . . . . . . . . . . . . . . . . . . . . 49
19.3.2 Unwanted Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

20 Coincidence 54

21 Point on Object 55

22 Vertical 56

23 Horizontal 57

24 Parallel 58

25 Perpendicular 58

26 Tangency 61

27 Equality 66

28 Symmetry 67

29 Block 72

30 Horizontal Distance 73

31 Vertical Distance 74

32 Lock 74

33 Length 75

3
34 Radius and Diameter 76

35 Angle 76

36 Further Dos and Don’ts with Constraints 79

37 Driven dimensions 81

38 External Geometry 83

IV Creating Objects Based on Sketches 87

39 Sketches for Pads and Pockets 87

40 Use Symmetry! 87

41 Placement and AttachmentOffset 87

42 Validate sketches 87

4
Introduction
This lecture was written for FreeCAD 0.19. Everything was tested with 0.19.21007 or newer.
The things described here may not all be available or may be looking differently in other
versions of FreeCAD.

Sketches serve as basic items in most PartDesign objects and they are often used in Part
workbench as well. In this lecture I will show how to create a sketch and how to handle the
different geometric elements and the different constraints.
Before working through this lecture you should make yourself familiar with how to create a
FreeCAD document and with the notion of a Workbench and how to change it. You should
know what the 3D view is and have basic knowledge about the organization of a PartDesign
body.

5
Part I

Basics
1 Create a sketch
There are two possibilities to create a sketch. Both are similar but not identical.

1.1 Create Sketch from Sketcher workbench


In Sketcher workbench you can create a sketch from the menu:
Sketcher→Create sketch, but you will probably rather use the icon . Depending on the
previous selection different things will happen.

• If nothing was selected you will be asked about the orientation of the sketch:

With the radiobutton you can control the plane in which you want to create the sketch.
Checking ”Reverse direction” will attach the sketch to the backside of the selected plane
like drawing on the backside of a sheet of paper. The ”Offset” moves the sketch in a
direction perpendicular to the selected plane.

• If you have selected a flat face, then the sketch is attached to that face, i.e. it is like
sketching on that face.

• If you need more sophisticated placement options see section 41 on page 87.

After clicking the OK button we enter Sketcher’s edit mode, in short we ”enter Sketcher”.

6
1.2 Create Sketch from PartDesign workbench

In PartDesign workbench you have the same icon , but as in PartDesign everything
happens inside of a body, when you click it here, the following things can happen:

• If you don’t have a body in your document, a new body is created, activated, and a
new sketch is created inside the body.

• If you have exactly one body in your document, the body is activated and a new sketch
is created inside the body.

• If an activated body exists, a new sketch is created inside that body. This is independent
from the number of bodies in the document.

• If more than one body exists and none is activated an error message is shown, asking
to activate a body.

In addition to this behavior, the following can happen depending on a previously made
selection:

• If nothing is selected, a new panel is opened and you have to select the orientation of
the new sketch either in the panel or in the 3D view to the right by selecting one of the
principal planes. In the image XZ plane is preselected:

At this early stage, leave all the checkboxes unchecked and click Ok.

• If a face or plane inside the active or the only body is selected, the new sketch is
attached to that face, i.e. it is like sketching on that face.

• If a face from outside the activated (or the only) body is selected a question is raised
how to link the face.
I don’t really recommend that workflow, I prefer to create the ShapeBinder myself for
better control of the faces included.

7
– The option ”Make independent copy” creates an unlinked ShapeBinder to which
the sketch is attached.
– The option ”Make dependent copy” creates a linked ShapeBinder to which the
sketch is attached. If you change the other object the ShapeBinder will follow.
– The option ”Create crossreference” creates a forbidden link (message: Links go
out of the allowed scope). I do not recommend to use this option at all.

You now enter Sketcher.

8
2 The Sketcher Window
We will not use all of the widgets in the Sketcher window, but a short look at those used will
hopefully help clarify what I talk about later.

OC
@
I
Geometric elements C
Constraints

XXX
y
Solver messages


Edit controls


List of constraints

3D-view


List of elements

Sketcher panel

3D view. Sketches are edited in the 3D view. Nevertheless sketches are strictly 2D.
The Sketcher Panel. At the left side you see the Sketcher panel in the Combo View. If
necessary you can switch to the Tree View and back.

9
There are different regions (or ”widgets”) in the panel controlling and displaying addi-
tional information about the sketch. You can collapse or expand solver messages, edit
controls, constraints and elements.

The Close button. Located at the top, it ends the Sketcher editing session.

Solver messages. Below the close button you see the solver messages showing ”Empty
sketch” until you add some elements to your sketch.
The Solver Messages area is very important and I advise you not to collapse it. Instead,
pay almost constant attention to it.

The grid. For now open the ”Edit controls” and uncheck the ”Show grid” checkbox. Al-
though the grid can be helpful when placing geometric elements, it is important to
know this:

• In Sketcher geometric elements placed at grid intersections are never secured to


the grid; they may move off the grid intersections if constraints are applied.
• Separate pieces of geometry that share a point at the same grid snap location
are not secured to one another, and they may move apart unexpectedly until a
Constraint is applied between those shared points.

If you have ”Grid snap” enabled it might seem that snapped points have their positions
already defined by the grid intersection, when in fact they are free to move. So I prefer
to have it switched off to avoid confusion.

The list of Constraints. This will be discussed later in this section. Leave the checkboxes
as they are, i. e. Filter set to All, ”Hide Internal Alignment” checked, ”Extended
Information” unchecked.

The list of Elements. This will also be discussed later in this section.

Sketcher Geometries tools. They are used to create points, lines, arcs, and other geome-
tries. You get the same list as a context menue if you click with the right mouse button
on an empty spot in the 3D view:

Sketcher Constraint tools. They are—roughly speaking—used to define the positions of


the geometric elements and their mutual relations:

Remark: On low resolution screens it is possible that only a part of a toolbar is visible. In
that case it is recommended to move the whole toolbar to a place where you can see all tools
are visible.

10
3 General Remarks on Degrees of Freedom
A sketch has certain geometric elements like lines and arcs which have certain positions on
the 2D sketch plane. These positions are controlled by measures or by other relations to
other points, lines or arcs. The number of possibilities where the elements can be moved is
the number of degrees of freedom, abbreviated as ”DOF”.
You can think about it as how many x and y measures you need to lock every point, be it
simply a lone point or a point at the end of a line or arc.

Exercise 1 Create a diagonal line where neither of the endpoints lies on the X or Y axis.

To do so

• Click the CreateLine icon . You see now near to the cursor a small red line symbol.

• Click where you want to place the first point.

• Move the mouse.

• Click where you want to place the second point.

• Click the right mouse button to leave the line creation mode. This behaviour can be
configured in
Preferences→Sketcher→Display→Geometry creation ”Continue Mode”.

Now solver messages and 3D view should look like this:

At the right side you see the line in the 3D view, at the left you see the solver messages
telling you that you have 4 degrees of freedom.

11
While the list of constraints in
the panel is still empty, the list
of elements shows the line we
have just created. If you hover
with the mouse over an element
it will be highlighted (turn yel-
low) in the 3D view.

Exercise 2 Add a horizontal distance constraint to the left lower point.

To do so

• Move the mouse over the left lower point until it is highlighted yellow. It is now as we
say preselected, i.e. you can select it.

• Click the left mouse button to select the point, it becomes dark green.

• Click the horizontal distance constraint icon . This creates a constraint between
the origin and the selected point. The proposed value is the current distance.

• Enter the value which you want to have and confirm. In my case the current value was
24 which I am about to change to 25 mm.

• Confirm with Ok.

Looking at the solver messages you see that the DOF have changed from 4 to 3:

12
The list of elements still contains the line and is unchanged. The list of constraints contains
now one element, the new constraint:

Exercise 3 Add a 30 mm vertical distance constraint to the left lower point.

To do so you perform the same steps as with the horizontal constraint, but now you use the
vertical distance constraint icon .

You can see that by applying another constraint you reduced the DOF to 2.
These simple constraints reduce the number of DOF by one, but there are more sophisticated
constraints which reduce the DOF by 2 or even 3. As an example, let’s do another exercise

Exercise 4 Add a coincidence constraint between the right upper end of the line and the
origin.

To do so

• Select the right upper endpoint as you have done with the other point before, it turns
dark green.

• Select the origin. You can do this by simply clicking as before, without holding any
additional key. We call this ”greedy selection”.

• Click the coincidence constraint icon .

Now three things have happened:

• The right upper point has moved to the origin.

• The solver reports ”Fully constrained sketch”. This is good; you should always fully
constrain your sketches. There are very few exceptions to this rule.

• The sketch turned from white to light green.

13
This is how it looks like now:

The list of elements still contains the line as before, the list of constraints contains now three
entries:

4 Auto Constraints
If auto constraints are enabled some constraints are created automatically. To see the differ-
ence between on and off we start switching them on.

4.1 Auto Constraints On


Exercise 5 Expand the Edit controls section of the panel and make sure that ”Auto con-
straints” is checked—which it is by default. Leave ”Avoid redundant auto constraints” checked
as well.

14
Now create another line in the following way:

• Click the CreateLine icon

• Move the mouse over the right upper point of the existing line. The point turns yellow
(hard to see, due to the red constraint lines) and besides the line symbol there occurs
an additional point near the cursor.

• Click left mouse button

• Move the cursor horizontally to the right

• Below the line appears a red marker indicating that a horizontal constraint can be
applied.

• Click to create the line.

15
The sketch has turned white again because it is no longer fully constrained and above the
horizontal line you see a small horizontal red line indicating that this line has a horizontal
constraint.

• The solver reports 1 DOF remaining.

• The list of elements now shows two lines. Hover over the list entries and watch the
corresponding elements turning yellow in 3D view.

• The list of constraints shows 5 constraints, the last two have been created automatically.

16
4.2 Auto Constraints Off
Delete the horizontal line, the sketch turns green again.
Open the Edit controls section and switch autoconstraints off.

Exercise 6 Create the horizontal line in the same way as you did with auto constraints
enabled.

The result looks almost the same, the only difference in 3D view is that the horizontal
constraint indicator is missing. The difference shows in the DOF, the list of constraints, and,
of course, in the behaviour:

• The solver reports 4 DOF.

• The list of constraints is identical to the state with only one line.

• Grab one of the endpoints and move it up and down. The other point will keep its
position, horizontally and vertically.

You can add the constraints manually thus leading to the same sketch as we had with auto
constraints enabled.
Warning: Enable auto constraints again before continuing.
General rules: You now know the very basic handling of Sketcher and should have learned
the following

• Adding a geometric element increases the number of DOF.

• Adding a constraint reduces the number of DOF.

17
Part II

Geometric Elements
In this part you will learn about the geometric elements. Some exercises rely on Auto
constraints, so once again, make sure that it is enabled.
In the usage part of the geometric elements I will use some of the constraints which are
not yet explained, so you may need to work through this section twice to fully understand
it. There was no better solution of the problem where to start. To explain the usage of
geometric elements I need some constraints, and to explain constraints I need, of course,
geometric elements. When using constraints in the part about geometric elements I restrict
the explanations of the constraints to a minimum. Their further usage will be explained later
in part III on page 45.
For further information refer to the documentation available online.

5 Common Usage
When you select one of the geometric element creation tools such as line, circle, arc, ... you
enter creation mode for an arbitrary number of these objects. When you enter creation mode
the cursor changes in 3D view to a cross and is augmented with information about its current
x/y coordinates and by showing a symbol indicating which kind of geometric object you are
going to create. Examples for line, arc and slot:

When you have created one of the geometric elements you are still in creation mode so you
can immediately continue creating the next object. This behaviour can be configured in
Preferences→Sketcher→Display→Geometry creation ”Continue Mode”. If you uncheck it in
the preferences, creation mode ends as soon as the element is created.
To end creation mode, you can click the right mouse button or hit the Esc (escape) key. The
latter is sometimes a problem, because if you are not in creation mode the Esc key ends the
sketch editing and closes the Sketcher; thus pressing twice Esc leaves creation mode and ends
editing. Polyline is a bit different as you need an additional right mouse click or Esc keypress
to leave the continuous mode.
I recommend to use the right click because you have the hand on the mouse anyway and
there is not the danger of leaving Sketcher unintendedly by one Esc keypress too much.
You can configure the behaviour of leaving using the Esc in the Sketcher preferences.

18
6 Line
Icon:
Number of DOF added: 4
The line is defined by the endpoints, each endpoint adding 2 DOF which sums up to 4 DOF.

Typical constraints
Coincidence on the endpoints In exercise 4 on page 13 we have used this already.
Horizontal constraint for a horizontal line. Select the line and click the horizontal con-
straint icon

The line becomes and will remain exactly horizontal.


Vertical constraint for vertical lines. Select the line and click the vertical constraint icon

The line becomes and will remain exactly vertical.

Equality Select two lines and click the icon

The lines will become and remain equal in length.

Horizontal distance Select the line and click the icon . Enter the distance in the
input field like you have done in exercise 2 on page 12
This is usually applied to horizontal lines, but is not restricted to them. If you apply it
to a sloped line, this constraint defines the horizontal distance between the endpoints.

19
Vertical distance Select the line and click the icon . Enter the distance in the input
field like you have done in exercise 3 on page 13
This is usually applied to vertical lines, but is not restricted to them. If you apply it
to a sloped line, this constraint defines the vertical distance between the endpoints.

Length Select the line and click the icon . Enter a value as you did e.g. for horizontal
or vertical distance.

Warning: Do not use this constraint for horizontal or vertical lines—unless you intend
to change the angle of the element in Sketcher later (for an example of this consider
turning a slot as in section 12 on page 36). Use the specialized constraints horizontal
distance or vertical distance instead. That makes it easier for the solver to find a
solution; see section 36 on page 79 for details.

It should be pointed out, that what we call a line is in fact only a line segment. This segment
lies on a line of infinite extent. This is of importance when point-on-object or tangency
constraints are involved (see sections 21 on page 55 and section 26 on page 61).

20
Exercise 7 Create the following sketch. It has exactly one measure and all short lines are
equal. Besides that the sketch has only coincidence, vertical, horizontal, and equality con-
straints.

In the state as shown here it has 1 DOF:

Target: the two selected lines must be on the same level. This can be achieved e.g. by
selecting the line to the left and a point to the right and apply a point-on-object constraint.

−→

21
7 Circle
Icons: (default)

Number of DOF added: 3


A circle can be defined by the position of its center with 2 DOF and the radius with one
DOF which sums up to 3 DOF.
Creation of circles comes in two flavors. As soon as the circle is created there is no difference
between the two methods.
1. The default method starts with the center and then adds the radius: After clicking
, click in the 3D view at the position where you want to place the center of the
circle. Move the mouse and watch the radius growing with the mouse position. Click
at a point which will then lie on the circle.
If you have auto constraints enabled you can select an existing point with a mouse click
which will create a point-on-object constraint.
2. To choose the alternative creation mode click the small triangle right of the create circle
icon and choose . Now you can click three points in 3D view which will all lie on
the circle. This creation mode will now be the default during your FreeCAD session
until it is changed again.

Typical constraints
Positioning the center can be achieved by any method used for positioning a point, this
includes, of course, coincidence, horizontal and vertical distance.

Radius/Diameter Select the circle and apply a radius constraint .

If you want to use the diameter instead, select from the radius icon’s drop down menu
the diameter icon . The diameter is often used for circles, while the radius is more
often used for arcs.

Equality Select two circles, or a circle and an arc and click the icon

22
The radius of each circle will become and will remain equal to one another.
Please note that equality between circle and a line is not possible, unless you use so
called Expressions, a subject out of scope here; see also the remark on arc length on
page 78.
Mathematical sidenote: To calculate the length of a circle was one of the most prominent challenges
in mathematics since ancient times. Nowadays it is proven that it is not solvable with finite precision.

Point-on-Object If you want to fix a point onto the circle, e.g. the endpoint of a line,
you can select the circle and the endpoint, and apply a point-on object constraint by
clicking .

Please note, that the sketch as it is shown here, can neither be padded nor pocketed
for two reasons: The sketch is not a closed shape and it has this junction of three lines
in one point. We call this situation a self-intersection. See section 39 on page 87 for a
detailed explanation.
Tangency There are usually two possibilities to create a tangency on a circle. Therefore
you should move all circles, lines or arcs involved as close as reasonably possible to
their respective final positions, before you apply a tangency constraint.
Tangency can be applied in two different ways to a circle.
• The endpoint of a line or arc can lie on the circle. Then select the circle and the
endpoint and apply the tangency constraint .

I should mention again, that this example can neither be padded nor pocketed
due to the self-intersection and lack of closed shape.
• The circle touches another circle, arc or a line. Select the circle and the line
or arc—Note the difference to the above; do not select a point!—and apply the
tangency with .

23
In this example I have done so twice, once on the X and once on the Y axis:

This kind of tangency can even be applied between a line and a circle without
them actually touching one another:

24
Circles are frequently used to create holes, either by pockets or by using the dedicated hole
feature. Although the latter does not make usage of the radius value, you should nevertheless
fully constrain your sketches.

Exercise 8 Select PartDesign workbench and create a sketch for a flange:

To center the squares we use the symmetry constraint: select the left lower corner and the
right upper corner and then the center. Finally apply the symmetry constraint .

This flange cannot be padded in the way it is now, because there are intersections between
the inner square and the small holes. We don’t need the inner square for the pad anyway, it is
needed only for the construction of the sketch. So we turn the inner square into construction
lines:

25
• Select the four sides of the inner square.

• Click the toggle-construction-mode-icon .

Now the inner square has changed its color to blue indicating that these are construction
lines, which don’t contribute directly to any sketch-based features, such as pads or pockets.

Close Sketcher and click the pad icon . This will create the flange:

26
8 Arc
An arc is a part of a circle and thus arcs share much with circles.

Icons: (default)

Number of DOF added: 5


An arc can be defined by the position of its center with 2 DOF, the radius with one DOF,
and an angle for each of the arc’s endpoints which sums up to 5 DOF.
Like with circles the creation of arcs comes in two flavors. As soon as the arc is created there
is no difference between the two methods.

1. The default method starts with the center and then adds the radius: After clicking
click in the 3D view at the position where you want to have the center of the
circle. Move the mouse and watch the radius follow the mouse. Click for the first point
of the arc. Move the mouse again and click for the second point of the arc.
If you have autoconstraints on you can select existing points which will create coinci-
dence constraints.

2. To choose the alternative creation mode click the small triangle right of the create arc
icon and choose . Now the first and second click define start and end of the arc
while the third click is an arbitrary point on the arc defining the radius. This creation
mode will now be the default during your FreeCAD session until it is changed again.

Typical constraints
Positioning the Center, Radius, Equality, Point-on-Object behave like they do with
circles

Tangency The two modes described for circles exist for arcs as well. But there is an ad-
ditional, most important mode to create tangency on the endpoints, which is called a
smooth joint .
Select one of the endpoints of the arc and the endpoint of a line or another arc. If you
now apply a tangency constraint two things happen:

• the elements are made tangential


• the points are made coincident.

27
Exercise 9 Create an arc and two horizontal lines. Apply point-to-point tangency con-
straints to the upper and the lower pair of points respectively. The left picture shows the
selection just before applying the first constraint, the right one shows the result after applying
both.

Exercise 10 Create the following sketch. All arcs have the same radius of 15 mm. The long
lines are equal. All short lines are equal. All tangencies are point to point tangencies with
smooth joints.

28
9 Polyline
Icon:
Number of DOF added: depending on the elements added (see below)
Polyline is a most useful tool for fast creation of a sketch. It is much more than just connecting
straight lines, there are several different modes of how to connect them and even arcs can be
created with this tool.
The polyline in its standard form adds a sequence of lines which are connected with co-
incidence constraints. These coincidences are independent of whether autoconstraints are
switched on or off. The continuation mode of the tool ends when the figure is closed, i. e.
when you connect the end point back to the original starting point of the polyline.
Alternatively you use the right mouse button or the Esc (escape) key to end the sequence at
any time. As mentioned above I recommend to use the right click on other systems because
you already have your hand on the mouse and there is not the danger of leaving Sketcher
unintendedly by one Esc keypress too many.
Like with the other geometry tools you stay in creation mode so you can immediately continue
with another polyline.
A further right mouse button click (or Esc keypress) ends the polyline creation completely.

Exercise 11 Create the sketch from exercise 7 on page 21, now using the Polyline tool.

It should be pointed out, that the results are the same whether a set of lines is created by
the polyline tool or with multiple single lines.
The polyline can do more than connect lines by coincidences. The following is taken from
the documentation with adding the DOF information:

29
The polyline always starts with a straight line segment: click - move the mouse - click. This
adds—like any other line—4 DOF to the model.
Move the mouse again. After placing the first line segment, the Sketcher polyline tool has
multiple modes that can be toggled with the M key. For example you can draw tangent
or perpendicular arcs following a line or arc segment. Repeatedly pressing the M key tog-
gles through the following different modes. The numbers of DOF are given ignoring auto
constraints, which can reduce the DOF further e.g. by applying an additional horizontal
constraint.

• Without pressing the M key a line with only the coincidence constraint is added. This
adds 2 DOF for the new endpoint.

• Press the M key: the new segment is a line which is perpendicular to the previous
segment. This adds 1 DOF.

• Press the M key again: the new segment is a line which is tangential to the previous
segment. This adds 1 DOF.

• Press the M key again: the new segment is an arc which is tangential to the previous
segment. This adds 2 DOF.

• Press the M key again: the new segment is an arc which is perpendicular (left) to the
previous segment. This adds 2 DOF.

• Press the M key again: the new segment is an arc which is perpendicular(right) to the
previous segment. This adds 2 DOF.

• Press the M key again: You are again in the state where you started; the line is only
connected with a coincidence to the previous segment.

• While in any of the arc modes, holding down the CTRL key (MacOS: CMD key) and
moving the cursor causes the arc to snap by increments of 45 degrees, relative to the
previously created polyline segment. In this case only 1 DOF is added instead of 2
because an angle constraint is automatically set.

30
Exercise 12 Create the following sketch using Polyline and the M key. All arcs including
the 45◦ ones have the same radius. The long lines are equal. All short lines including the 45◦
ones at the right have the same length.

10 Rectangle
Icon:
Number of DOF added: 4
The predefined rectangles in Sketcher have always horizontal and vertical lines only. Such
a rectangle can be defined by two of its diagonal points, each of them adding 2 DOF which
sums up to 4 DOF.
To create a rectangle you click the first corner and then the diagonal opposite corner. The
result is the same as if the rectangle was constructed by four lines connected with coincidences
and constrained with vertical and horizontal constraints.

Centering of Rectangles
Often a rectangle has to be placed in the center of the coordinate system. Or some other
point should be positioned in the middle of the rectangle (cf. exercise 8 on page 25).

31
To achieve this you select two diagonal points and as a third point the center and apply a
symmetry constraint . This is better than applying a symmetry constraint between a
horizontal side and a vertical axis, then another symmetry constraint between a vertical side
and the horizontal axis. It is important to select the center last, as you will see in section 28
on page 67.

11 Polygon

Icons:

Number of DOF added: 4


The center has two DOF, the diameter adds one DOF and the orientation is the last of the
four DOF. This is independent of the number of edges of the polygon.
When you create a polygon you start in the middle and move the mouse to define the outer
radius and the position of one corner. The blue outer circle is construction geometry and
thus not contributing to further usage of the sketch in pads and pockets.
The most frequently used polygon is probably the hexagon in connection with nuts and bolts:

32
As a polygon is a set of lines and a (construction) circle, all advice given before holds here
as well.
If the first constraints you add are fixing the center of the polygon, make sure that the
intended target is close to the current center, i. e. you should move the polygon near its final
position. If the target center is outside of the circle the polygon can collapse to something
unusable. Fixing the size of the polygon prevents this from happening.

12 Slot
Icon:
Number of DOF added: 4
The center of one of the circles has 2 DOF. The predefined slot is always horizontal or vertical,
so the distance to the other center adds 1 DOF, and the radius adds 1 DOF as well, which
sums up to 4 DOF.
Creating a slot starts with a click in the center of one half circle. The next click defines the
radius and the length of the slot. Depending on the relative position of the second click the
slot is either vertical or horizontal.

33
Exercise 13 Create a sketch for a block containing a slot for a sliding mechanism:

Remark: For now we position the slot with measures. We will learn in section 28 on page 67
about symmetry how to center the slot.

Typical constraints
Beyond the constraints you know already for lines and arcs I want to show how to constrain
a slot if the overall length of the slot is known and should thus be used directly in the sketch.

Exercise 14 Create the same sketch for a sliding mechanism as before, but now setting the
overall distance:

This sketch is not yet fully constrained, it misses the overall positioning in x and y.

34
To create the sketch:

• Create rectangle and slot as before.


• Create a point and place it with a point-on-object constraint on one of the arcs. It is
best to place it already near its final position. If you have autoconstraints enabled you
can do this in one step.

• Do the same for the other arc.


• Select the new point and the center of the arc and apply a horizontal constraint. The
image shows the situation after having applied the constraint. I have selected the
elements involved, they show in green.

• Do the same for the other arc.


• Apply a horizontal distance constraint on the outer points.
• Apply the other constraints as before.

Tilted Slots
The predefined slots are either horizontal or vertical. This is sensible because most slots are
oriented like this and they can be created with just two clicks. However, if you need a tilted

35
slot it can be achieved by simply deleting the horizontal/vertical constraint. This will of
course add another DOF. In the image I have added already an angular constraint:

13 B-splines

Icons: open B-spline

closed B-spline
Number of DOF added: 3 for each control point
Each control point is defined by a circle with 3 DOF.
B-splines are curves which are used for smooth surfaces. They are determined by a set of
control points, which themselves—except start and end—do not have to lie on the B-spline.
Each control point has a weight, which determines how much the control point ”attracts”
the curve. B-splines often occur when you import Scalable Vector Graphics (SVG) files and
apply Draft-to-Sketch.
There are two variants of B-spline:

The open B-spline has a start, which is the first control point and an end, which is
the last control point.

The closed B-spline is created in the same way, but when creating ends, the B-
spline’s end is smoothly connected with the start.

36
Exercise 15 Create a B-spline with the following control points. The absolute distances
between the points don’t matter at the moment.

Start at the left, add the upper control point and finally the right one. Finish the B-Spline
creation with a right mouse button click or use the Esc (escape) key. The B-spline is created
with the same size for all circles around the control points. Please note that the B-spline is
not shown until creation is completed.
You have two possibilities to influence the shape of the B-spline with the upper control point
(of course, the same possibilities exist for the other points too).
• The position of the control point determines the direction and how much the B-spline
is deviated:

You see how the curve is attracted by the control point. The ratio between the control
point, the curve, and the other points remains approximately constant.
• The size of the circles around the control points determines how much the curve is
attracted. The bigger the circle the more is the B-spline attracted. An infinite circle
would attract it up to the control point itself.

37
Before changing the size of a single control point you have to remove the equality
constraint.

Typical constraints
B-splines support all constraints seen so far on the control circles.
It is not (yet) possible to use constraints like tangency or point-on-object in the curve of a
B-spline but only on its endpoints; however, below you find some techniques how to simulate
this.

Block constraint. While it is very sensible to use other than block constraints on the
endpoints it might clutter the sketch with measures if you want to constrain all the
control points in between.
Here it is sensible to use the block constraint on the B-spline. Make sure you have
applied all other constraints before, because once the block constraint is applied nothing
can be changed on any point of the B-spline.1
1
As of v. 0.19.21007 the Sketcher doesn’t report such overconstraints.

38
Exercise 16 Create a B-spline according to the following image. The block constraint
is aligned rather far on the left, but it belongs to the B-spline curve.

Before applying the block constraint specify the overall length (55 mm), and adjust the
size of the bigger circle (without setting it as constraint).

Tangent and Perpendicular Constraint on the endpoints. Arcs and lines—and with
the help of a construction line even B-splines—can be connected at their endpoints
using tangent or perpendicular constraints.

Exercise 17 Remove the block constraint from exercise 16. Attach horizontal lines,
tangential to the left, perpendicular to the right.

−→ −→

The last action would be to add the block constraint again.

Tangent Constraint on the curve. It is currently not possible to create a tangent on the
inner part of a B-spline. The same holds for points lying on the curve.
As a workaround you have to create two B-splines and connect them tangentially. That
doesn’t work directly either so you have to add a construction line.

39
Warning: You will not get automatically exactly the same curve as with a single
B-spline, but you can get very close.

Exercise 18 Based on exercise 16 on the previous page add a tangent to the top of the
B-spline.

There are two B-splines involved:

and

There are different possibilities to add the tangent:

• You can place the endpoint and the control point next to it on the tangent. That’s
what I have done in the example.
• You can use tangent point-to-point constraints on the endpoints.

Point-on-Object on the curve. Create this in an analogous way as the tangent.

40
Perpendicular on the curve. Create this in an analogous way as the tangent.

14 Conical sections
You find the conical section in the dropdown menu of the icon . Once you have selected
one of the options, the icon is replaced with the last chosen selection.

Icons: Ellipse by Center, minor an major radius, 5 DOF

Ellipse by major and minor axis, 5 DOF

Arc of ellipse, 7 DOF

Arc of hyperbola, 7 DOF

Arc of parabola, 6 DOF

The DOF of the ellipse are given by the two defining lines which would make up to 8
DOF. These are reduced by the lines having a common center (minus 2 DOF) and being
perpendicular (minus 1 DOF). This sums up to 5 DOF.
The arc of ellipse has 2 additional DOF: start and endpoint can each be defined by an angle
adding one DOF each. This sums up to 7 DOF.
A hyperbola is again defined by two perpendicular lines—this time connected like a T—and
two angles, which sums up to 7 DOF
A parabola is defined by a line between focus and vertex with 4 DOF and two angles for the
endpoints. This sums up to 6 DOF.

14.1 Creating and using conical sections


Usage of conical sections is straight forward. There is one exception of special behaviour
when using tangents which will be described below (see section 14.2 on the following page).

• You can use the construction lines (see section 15 on the next page) for further con-
straining your model.

• You can use the curve in the same way as was described for circles and arcs:

– add tangency constraints between curve and lines


– add point-to-point tangency between endpoints of conical arcs and other geometric
elements
– add perpendicular constraints between endpoints of conical arcs and other geo-
metric elements

41
14.2 Tangency and perpendicular on conical sections
If you want to create a tangency constraint between a conical section and another curve of
type conical section, circle or arc you do so in the same way as usual: Select both curves and
apply the constraint. However, the effect is slightly different:

• An additional point is created;


• This point is placed on both curves with two point-on-object constraints;
• A tangency constraint is created.

The same technique is used to create a perpendicular constraint between a conical section
and a line:

15 Construction Geometry
Construction geometry can be used when the geometry won’t be used for creating further
features but only to construct the sketch itself. We have used it ourselves already in exercise
8 on page 25, and it is generated automatically e. g. when creating a polygon, see section 11
on page 32.
Construction geometry comes in blue color to distinguish it from what I will call here ”real” or
”normal” geometry, which comes in white. You have two possibilities to create construction
geometry:

• By selecting a geometric element and clicking the toggle-construction-mode-icon


you can toggle between construction and real geometry. That means you can also go
the other way and turn construction geometry into real geometry.

42
• If nothing is selected and you click toggle-construction-mode-icon , all icons for
creating geometry turn to blue and you enter construction mode. In this mode all
geometric elements are construction elements.
To end this mode, hit the toggle-construction-mode-icon again.
I frequently use construction geometry when I want to have equal distances to some outer
border of a sketch
Exercise 19 Create a nontrivial sketch with an inner and outer border of equal distance
between them.

To do so:
• Start with a fully constrained sketch of the outer border
• Add the inner border with the same structure. Your sketch will roughly look like this

43
• Switch to construction mode

• Add the construction lines. With autoconstraints on you can add horizontal, vertical
and point-on-object constraints during construction. If some are missing, apply them
after creation.

• Apply an equality constraint between all construction lines.

• Add a horizontal or vertical distance constraint to one of the construction lines.

Construction geometry is added to the list of elements like all other geometry as well. The
corresponding icons have blue dots at the ends instead of red.

16 Point
The point is a geometric element we havent discussed yet. It cannot be toggled between real
and construction geometry, it is always construction.

Icon:
Number of DOF added: 2
The point can be constrained fixing the x and the y coordinate, thus having 2 DOF.
The point serves only as construction geometry. It is not possible to construct a sketch
containing only a point as real geometry. (That would be desirable for Lofts which end in a
single point.) This holds for the current version of 0.19, it might change in the future. If you
need such a point as real geometry you have to use Draft or Part workbench.
Use the point to define the rest of the sketch in case a point is needed, but isn’t given directly
by the geometry. This can be e.g. the center of two rectangles, a certain point on a circle,
etc. For an example see the slot exercise 14 on page 34.

44
Part III
Constraints
The constraints make the Sketcher unique among the workbenches and distinguish it from
most other 2D drawing programs as well. Especially the geometric constraints like coin-
cidence, equality, point-on-object, tangency, etc. make a model independent of too many
dimensions thus improving readability and parametricity. Imagine a sketch with a single slot
and you had every single point constrained with x- and y-measure. That would sum up to
18 measures. And now imagine you had two or three of those slots and you had to move
this sketch a certain amount up and to the right. You would have to change and to calculate
every single of these measures—what a pain.
In this section I want to discuss the different constraints and how they are handled.
While geometric elements add DOF to a model, constraints are doing the opposite: they
reduce the number of DOF. Below I will say a constraint consumes a certain number of
DOF. This is something you should always have in mind. I am always watching the solver
messages and how they change on application of a new constraint. This gives me some
satisfaction seeing the approach towards zero, but it is of course more important, that I can
intervene immediately if something goes wrong.

17 Selecting Constraints
This seems to be a simple task, but there are more possibilities beyond the obvious way.
Whenever you select a constraint by any of the means below, the constraint will be selected
in 3D view as well as in the list of constraints in the panel to the left.

Click on the constraint in 3D view This is probably the most frequently used possibil-
ity.

Double click on a numerical value in 3D view such as distance or radius. If you want
to change the value of a measure, double click on the constraint and enter the new
value.

List selection Sometimes it is difficult to select an existing constraint in the 3D view. In


the current 0.19 version it seems to be impossible to select one of multiple constraints if
more than one is attached to a geometric element (on the Mac this seems to be slightly
worse than on Ubuntu).
In that case you can select it from the list of constraints in the panel at the left side.
This is the safest way to determine the last constraint added, as it is the last in the
list.

Select constraints associated with a geometric element If you have selected a geo-
metric element, you can use the icon to select all the associated constraints in-
cluding coincidences at the endpoints. At the same time the selection of the geometric
element is discarded.

45
Select geometric elements associated with a constraint If you have selected a con-
straint, you can use the icon to select all the associated geometric elements. At
the same time the selection of the Constraint is discarded.

Box selection This selection type is—as far as constraints are concerned—useful for select-
ing coincidence constraints. On the other hand it can be used to select endpoints of
geometric elements which lie on top of each other, e. g. in order to apply a tangency or
perpendicular constraint:
You can draw a rectangle while holding left mouse button down. Depending of the
direction of the selection different things happen:

• From left to right all Elements, that are completely inside of the selection rectangle,
are selected.
• From right to left all Elements, that are at least partially inside of the rectangle
are selected.

See exercise 22 on page 54 for a box selection example.

18 Applying constraints
There are two different modes for applying constraints to geometric elements. The behaviour
can be configured in
Preferences→Sketcher→Display→Constraint creation ”Continue Mode”.

• You can apply a constraint as before in this lecture: Select one or—depending on the
type of constraint—more geometric elements and then click the icon for the constraint.

• The other mode is similar to continuous creation mode of geometry: Without having
selected any geometric element in the sketch click a constraint icon. As an example
let’s say you clicked the vertical constraint icon. You can now select subsequently all
the lines which are supposed to have a vertical constraint.
For constraints that require selection of more than one geometric element like point-
on-object the constraint is applied as soon as you have selected enough elements. With
some constraints like symmetry the sequence of the selection is meaningful.
To end continuous constraint mode click the right mouse button or hit the Esc (escape)
key or select something else from the geometric elements list.

19 The Solver

19.1 Solving a Sketch


For the solver a sketch is a—possibly huge—system of equations. The solver tries to find a
solution which in the best case is unique.

46
A sketch is said to be solved, if all constraints are fulfilled and there is no other ”near-by-
solution”, i.e. you cannot move some part of the sketch continuously while the solution is
still valid. This condition is a bit complicated, because a sketch can well be marked as solved
although the solution is not unique. The following exercise shows two sketches which are
both fully constrained and have both the same set of constraints. Yet they are different!

Exercise 20 Create a sketch according to the following image

Left and upper side are equal. The three short lines are equal.
Now we will create a different solution based on the same set of constraints:
• Remove the equality constraint from the short horizontal line. In the image it is con-
straint number 17.
• Move the right end of the sketch to the left. Move it until the lower short vertical line
is left of the upper short vertical line.
• Apply the equality constraint again, and you have the same set of constraints as before.

47
19.2 Flipping Sketch
The behaviour sometimes leads to unexpected results, because multiple small changes lead
to different results than one big change.

Exercise 21 Create a sketch according to the following image

Now increase the length of the upper line in two steps to 60 mm

The sketch behaves like expected.

48
Now go back to the 10 mm version and change it in one step to the final 60 mm:

The left horizontal line has flipped its direction. If this happens to a sketch I usually undo the
last action and move the elements manually as close as possible to their final destination.2

Increase robustness You can improve robustness if you use angle constraints of 90◦ in-
stead of horizontal or vertical constraints (see section 35 on page 76). However, it is not
advised to do this always, because it puts more stress on the solver and spoils the sketch.

19.3 Solver Messages


Whenever you do something that changes the DOF, like adding or removing a geometric
element or adding or removing a constraint, the solver recalculates the whole Sketch to
determine a solution and responds with a certain message. Some of them are desired in the
process of developing a sketch and some show error states.

19.3.1 Messages you want to see

Under-constrained sketch Let’s recall the two lines example about autoconstraints from
section 4.1 on page 16:

2
In Preferences→Sketcher→General you can select the option ”Show section ’Advanced Solver Control’
in task dialog”. After reopening Sketcher you have an additional subsection Advanced solver control in the
panel. If you select Levenberg-Marquardt as default you often can avoid jumping sketches.

49
You can click on the blue part in the solver message, here it says 1 degree. This will
select elements in the sketch where additional constraints should be applied for further
constraining. In this example the upper horizontal line will be selected.
There cannot be any further recommendation about how to constrain the sketch, be-
cause it is up to you. Think about it and apply the appropriate constraint. In this
case it could be a horizontal length or an equality constraint. Even a point-on-object
constraint would be possible between the endpoint and the Y-axis, thus flipping the
line by 180◦ .
Fully constrained sketch in friendly green color. This is what you should always try to
achieve!

Sketches can be used for pads and pockets without being fully constrained, but experi-
ence has shown that in some rare cases there were issues with using sketches that were
not fully constrained.

19.3.2 Unwanted Messages

There are different issues of different severeness, most of them detected and reported by the
solver.
Please note: When the sketch is in such an error state it is no longer updated in
3D view. You cannot move the sketch or parts of it, further constraints which
might well be correct don’t show any consequences in the view until you have
corrected the error.
The following is ordered by severeness, worst coming first:

Sketch unsolved In the sketch below I had applied a symmetry constraint on the endpoints
of the line and the Y-axis. This made the line horizontal and had left 2 DOF. Then I
have added a (contradicting) vertical constraint on the line. This left the message as
before, but added ”Unsolved” in red. You should handle it by deleting the constraint
added last, because the solver cannot give you any hints on the constraints involved.
This shows once again the importance of always watching the solver messages.

50
This situation comes in different flavors, depending on the solver message you had
before you added the conflicting constraint. If you close and reopen the sketch you get
the message ”Undefined degrees of freedom”.

Sketch contains conflicting constraints In this example

I have applied a coincidence constraint on the two selected points. Of course this is not
possible because they cannot be 10 mm apart and coincident at the same time. The
solver detects and reports this.
The solver lists all candidates of constraints of which you should delete at least one.
You can click on the blue part in the solver message, which will select all of these
candidates. If you delete them you will have deleted far too much.
If you always watch the solver messages you will realize immediately that something
is wrong. So you should analyze why the last constraint leads to this error message.
Most often you will remove the last constraint and replace it with the right one. In the
example given here a horizontal constraint or a vertical distance could be
appropriate.
In some cases it can be sensible to remove or replace some other constraint than the
last one. In the example the 30 mm constraint could be removed, after which the
coincidence could be applied without errors.

Over-constrained sketch This is a special form of the previous one, with the additional
condition that there are more degrees of freedom consumed by the constraints than
are added by the geometric elements. In the following example I have a fully and well
constrained Sketch with one horizontal line. It’s length is defined and it is symmetric
to the origin.

51
If now an additional coincidence constraint is applied to the right end of the line and
the origin, then there are too many constraints and they are conflicting.

Sketch contains redundant constraints You get this message when a constraint is im-
plied by one or more of the other constraints. In the following example I had the line
with a horizontal constraint. Then I selected both endpoints and the Y-axis and added
a symmetry constraint. The symmetry implies the horizontal constraint. The solver
detects this, and makes in this case a perfect proposal which I can follow by clicking
on the blue ”click to select” and delete it.
Please note that in this case it is not sensible to remove the last constraint added.

(normal display) showing DOF or even the ”fully constrained” message. But yet it is over-
constrained. This is not too serious, and everything works as expected, but I recom-
mend to avoid it nevertheless, because you usually could simplify the set of constraints,
and simpler is always better, if the result is the same.
These overconstraints occur when a constraint is added which consumes more than one
DOF, and there is no other constraint which can be removed completely. The solver
silently drops the redundant part of a constraint.
As an example create a sketch in the way described below:

• Create an equilateral triangle and fix the length of a side. You have 3 DOF.

52
• Add a symmetry constraint making two points symmetric to the x-axis. This
consumes 2 DOF leaving 1 DOF.

• Create a coincidence constraint between the point positioned on the x-axis and
the origin.

Coincidence consumes 2 DOF, so a redundancy could be expected; however, the


solver detects this as correctly fully constrained.

As said before, you should always watch the solver messages in order to detect these
issues. It should be noted that in these cases a different sequence of applying the con-

53
straints can lead to different results. If you create in the example above the coincidence
first and then the symmetry you get an ”unsolved” sketch.
A proper way to constrain this would be to replace one of the constraints consuming
two DOF by a constraint consuming only one. You could e.g. replace the symmetry by
a vertical constraint or the coincidence in the center by a point-on-object on the y-axis.

20 Coincidence
Icon:
Number of DOF consumed: 2
The coincidence stops a point from moving in two directions, thus consuming 2 DOF.
There is an important difference between two points having the same coordinates and being
coincident. Especially when you have grid snapping enabled this can lead to confusion. The
following exercise will show the difference and shows the technique of Box Selection, which
comes in handy when dealing with coincidences.

Exercise 22 Create a fully constrained rectangle, which means you have 0 DOF.

Now select one by one the upper corners with box selection from left to right and remove
what’s in the box.

54
This will leave the sketch with 4 DOF, although the position of all geometric elements is
exactly the same as before. If you want, you can now move the upper line, which wasn’t
possible before.

With some experience—as soon as you are sure whether two points are coincident or only
look like— you will probably use box selection the other way round: Select the endpoints
with box selection and apply the coincidence.
For beginners I like to recommend something else: Move one of the points you want to have
coincident, being fully aware that it is off its final destination. When you apply the constraint
you can see it snap into position.
See section 42 on page 87 for an additional tool to check if you have missed any coincidences.

21 Point on Object

Icon:
Number of DOF consumed: 1
A point-on-object constraint fixes a point e.g. on a horizontal line in vertical direction, while
it still can move on the line. This consumes 1 DOF.
Very often point-on-object is used to fix a point on X or Y axis. But it can be used to fix
a point on a line as well as on a curve. This constraint cannot yet be applied on B-splines.
If nothing else is fixed the point can move on the line or on the arc respectively. In exercise
7 on page 21 we have already seen, that it is not necessary that the point lies on the line
segment forming the geometry. The same holds for arcs or other curves.

Exercise 23 Create a sketch according to the following image using point-on-object con-
straints on X-axis (twice) and Y-axis.

55
The center of the circle is coincident with the origin. There is one DOF left, because the
lower point can move freely up and down the Y-axis.
We fix the last DOF with another point-on-object constraint. Select the lower point and the
arc and apply point-on-object:

−→

The lower point lies now on the virtual extension of the arc.

22 Vertical
Icon:
Number of DOF consumed: 1
The vertical constraint is usually applied to lines, and—as name and icon suggest—defines
the orientation of the line being vertical.
Here are some remarks concerning the application of vertical constraints:

• After having created a rough outline of a sketch it can be sensible to enter continuous
mode for applying vertical constraints. See section 18 on page 46 for details.

56
• You can select more than one line and apply vertical to all of them at once. Although
this seems to require the same effort as the continuous mode there is an important
difference: If you miss a line and click in the free area all previously selected lines
are deselected. So be careful if you have lots of verticals or apply the constraint after
selecting only some of the lines.

• Vertical constraint can be applied to points instead of lines. Select two or more points
and apply the vertical constraint. This aligns the points vertically stacked, without
needing any further construction elements.
This is frequently used if you want to access the topmost or bottommost point of an
arc or circle.
A horizontal distance measure of 0 mm which has the same effect should be avoided.

Exercise 24 Create a slot according to the following image:

The top and bottom point in the slot are additional Points, see section 16 on page 44 for
details. They have a vertical constraint with the center of the lower arc.

23 Horizontal
Icon:
Number of DOF consumed: 1
Everything which has been said about the vertical constraint applies for the horizontal con-
straint as well, with the only difference, of course, that instead of vertical, lines and points
are aligned horizontally.

57
24 Parallel
Icon:
Number of DOF consumed: 1
This constraint limits the orientation of a line – like a vertical or horizontal constraint – to
a certain direction and consumes 1 DOF.
Select two or more lines and click the icon . This makes all selected lines parallel. In
continuous mode you can select subsequent pairs of lines which are then made parallel.

Exercise 25 Create a sketch according to the following image. Use continuous mode.

There are two cases where you cannot or should not use parallel constraints.

• You should not use parallel on vertical or horizontal lines. Use the dedicated vertical
and horizontal constraints instead

• You cannot use a parallel constraint on arcs or circles. If you want to have concentric
circles you should make their centers coincident.

25 Perpendicular

Icon:
Number of DOF consumed: 1 for line/line; see paragraph (a) below
2 for point/line; see paragraph (b) below
3 for point/point; see paragraph (c) below
The perpendicular constraint comes—similar to the tangency in section 26 on page 61—in
three different flavors, controlling different behaviour on the endpoints.

58
(a) For the basic variant select two lines and apply the perpendicular constraint. The fol-
lowing example shows, that the lines don’t have to cross to be perpendicular:

Exercise 26 Create two lines with considerable distance between them and apply the
perpendicular constraint:

−→

The perpendicular constraint can be applied between a line and a circle or an arc as well:

−→

Remark: A point-on-object constraint between the center of the arc and the line would
have the same effect.

(b) If we select a line and an endpoint of another line before applying the perpendicular
constraint we get the same perpendicular arrangement as before, but now the endpoint
is also constrained on the line:

−→

To be precise: the point does not lie on the real line segment, but on the infinite line:

59
−→

Again we can apply this constraint on a line and an arc:

(c) If you select the endpoints of two lines or of an arc and a line or of two arcs and apply
the perpendicular constraint the two lines / arcs are made perpendicular and the selected
points are made coincident. This is the type of perpendicular constraint that is created
automatically with the polyline using the M-key, see section 9 on page 30.

−→

−→

60
−→

Things you should not or cannot do

• You should not use the perpendicular constraint to create vertical or horizontal con-
straints. Use always the simplest constraint possible, which is in case of horizontal lines
the horizontal constraint (see section 23 on page 57) and for vertical lines the vertical
constraint (see section 22 on page 56).

• You cannot use a line-to-line perpendicular constraint on two circles or arcs. However,
using a construction line and tangency you can well achieve this target. We will come
back to this at the end of the section about tangency (see exercise 28 on page 65).

26 Tangency
Tangency comes in different flavors controlling different behaviour on the endpoints.

Icon:
Number of DOF consumed: 1 (curve/curve)
2 (point/curve)
3 (point/point)
2 (line/line)

Curve to curve, including line to curve Take a line where one endpoint is fixed. There
are 2 DOF left for the other endpoint. If the line touches a given circle, there is only 1
DOF left, because the point can be moved only in the fixed direction of the line. This
results in 1 DOF for this curve/curve type of tangency.
Please note that the green color in the left image is not signaling that it is fully con-
strained, it is the selection before applying the tangency constraint.

61
−→

Similar to point-on-object constraint when applying a curve/curve tangency constraint,


the tangent elements don’t have to touch:

Point to curve. If in the same situation the endpoint of the line should touch the circle,
then nothing can be moved at all. This means that point/curve consumes 2 DOF.

−→

62
Point to point. If you have a fixed arc and attach the endpoint of a tangent line to one of
the arc’s endpoints you have fixed the free moving point (2 DOF) and the direction (1
DOF). This means that point/point tangency consumes 3 DOF.

−→

Line to line Assume one fixed line and a second line without any restrictions. If a tangency
constraint is applied between the lines, they are made collinear, i.e. they now lie both
on the same infinite line. This fixes both endpoints to lie on that line thus consuming
2 DOF.

−→

63
Exercise 27 Create a sketch for a flange of the following shape. Use the polyline tool for the
outer part, using the M key to toggle polyline mode. The small holes have the same diameter
(10 mm). The outer arcs have the same centers as the small holes.

There is a curve/curve tangency of the inner circle and one of the triangle’s lines, and the
same kind of curve/curve tangency between the blue construction circle and the outer upper
straight line.
If you have closed the outer polyline while creating it, there is a coincidence constraint created
where you actually want to have point to point tangency. To achieve this we have several
possibilities:

• You select the coincidence using box selection and remove it before applying tangency.

• You select the coincidence in the panels list of constraints and remove it before applying
tangency.

• If you have enabled automatic removal of redundant constraints, the coincidence will
be removed automatically on creation of the point/point-tangency.

• If automatic removal of redundant constraints is not enabled, you can nevertheless


select the endpoints using box selection and apply tangency. The solver notices the

64
redundancy and will complain with an appropriate message. By clicking on the active
part of the message you can select and remove the coincidence.

• Select the edges instead of the points and apply a curve/curve tangent constraint. The
solver detects this and replaces the constraints appropriately.

Now that you know this you would of course have avoided this situation alltogether by not
connecting the last point when creating the outer edge.
For now you can either select the coincidence from the list or using box selection or by simply
clicking on the link in the solver message and delete it.
As promised in the section about perpendicular constraints, we can now work through the
following exercise

Exercise 28 Construct two arcs which have a perpendicular intersection

To do so:

• Create the arcs

• Create a construction line with a point/line perpendicular constraint on one of the arcs
and the endpoint of the line:

• Create a point/line tangent constraint on the other arc and the same endpoint of the
line:

65
27 Equality

Icon:
Number of DOF consumed: 1
If you have a line with one of the endpoints fixed, you can move the other point with its 2
DOF freely. If you fix the length of the line with an equality constraint you reduce the DOF
by one. Thus equality constraint consumes 1 DOF.
You can either apply equality to two lines or to two arcs or arc and circle. Mixing line and
arc is not possible. For arcs and circles the equality constraint makes their radii (not edge
length) equal.

−→

−→

−→

66
28 Symmetry

Icon:
Number of DOF consumed: 2
Making a point with its two DOF symmetric to a fixed point will remove both DOF; thus
the symmetry consumes 2 DOF.

Warning: Symmetry is—from what I have seen—the constraint which raises issues more
often than other constraints. So read this section carefully to avoid any problems. Some
issues are not yet solved, they mostly occur in connection with symmetry and arcs. DOF
detection does not always show correct values.
Symmetry comes in two flavors, the point-point-point variant and the point-line-point variant.

Point-point-point symmetry This variant of symmetry arranges three points so that they
lie on a (virtual) line and the outer points have equal distance to the point in the middle.
To apply symmetry select first both outer points and finally the point in the middle.
It is good advice to arrange the sketch before applying symmetry so that all points are
near their final position!
The different geometric objects, line, arc, and point, in the following exercise are for
demonstration purpose only, distinguishing which points are affected.

Exercise 29 Create a sketch according to the following image and apply symmetry
after selecting the points lower end of the line and lower end of the arc and the single
point in different orders, so that each of the points comes last once.

Here are the three different solutions:

67
End of line last:

End of arc last:

Single point last:

In the last case the center is hard to see, because the single point vanishes below the
symmetry marks in the center.

Special case of point-point-point symmetry: If you want to fix a point in the


middle of a line you can simply select the line and the point and apply the symmetry
constraint. The selection order doesn’t matter here:

−→

Point-line-point symmetry This variant of symmetry arranges two points so that they
are mirrored at the line. In this case the sequence of the selection doesn’t matter:

68
−→

Exercise 30 Recreate the sketch from exercise 13 on page 34. The slot has to be centered in
the surrounding rectangle.

Hint: Use an additional point (see section 16 on page 44) in the center of the rectangle and
the slot.

69
Warning: If you create a rectangle or use autoconstraints which automatically create hor-
izontal or vertical constraints a common use case is to apply later a symmetry constraint. In
that case the horizontal/vertical constraint is implied by the symmetry.

No:

See the vertical constraints at the right and horizontal at the bottom? Delete them:

Maybe:

Even better: Use one horizontal constraint, one vertical constraint, and apply a symmetry
constraint between the lower left endpoint, the upper right endpoint, and the origin:

Yes:

The two remaining DOF are the horizontal and the vertical length.

Things you should not do

There are cases where symmetry can be applied, but it consumes only one DOF. This happens
often in connection with arcs, where additional implicit constraints come into play.
There are two possibilities of what can happen - depending on some yet unknown condition:

70
• The solver shows 1 DOF after applying symmetry

This is surprising, because there are indeed two DOF: one for the radius of the arc, and
one for the vertical position or the distance of the ends. If one of those is applied, the
number of DOF remains at 1, which is correct. Yet the number of constraints consumed
doesn’t match the sum of the DOF of the constraints.

If the horizontal constraint is removed again, the DOF are shown correctly as 2.

• After applying the symmetry constraint the solver shows 2 DOF

which again can be seen as surprising, because it means that symmetry consumes only
one DOF.

71
In both cases the solver is smart and silently drops part of a constraint. It doesn’t show a
redundancy warning, because none of the other constraints could be removed without loosing
DOF.
In many cases this works well, but I have seen quite some cases where it caused problems. So
I would strongly recommend to avoid such constraining. In the example given here it would
be better not to use symmetry at all, but e.g. a horizontal constraint instead. This reduces
the DOF as expected by 1:

29 Block
Icon:
Number of DOF consumed: 1 - arbitrary
The block constraint consumes all remaining DOF of a line or an arc, which can be 1 e. g. for
a partially constrained line, up to 5 for an arc without any other constraint. For B-splines
this number can be arbitrarily high.
The block constraint fixes both ends of a line, center and radius of a circle, center and both
endpoints of an arc in their current position / dimension.
You apply it to lines, circles and arcs, not to points. That means you cannot select the whole
sketch and fix everything, you have to select the lines and curves.

Exercise 31 Create a new Sketch and enter Sketcher. After that, create the following Sketch
from scratch with no more than 9 clicks from zero to being fully constrained. In the image
the constraints are hidden.

72
Solution:

clicks action
1 select Polyline tool
5 create the closed shape, use the M key to change the continuation mode
1 select block constraint
2 select two opposite elements

Warning: The block constraint looks intriguing if you want to fully constrain a sketch, but
in most cases it is not advised to use it for common engineering tasks. You should not use it
simply because you are lazy. Here are some use cases where the block constraint is sensible:

• You have traced an image with tens if not hundreds of points and want to fix them.

• You have a complicated B-spline with many control points which are not related.

• You want to move some points of your sketch and other things should not move yet.
Then you apply some block constraints, move the elements, and remove the block con-
straints again.

30 Horizontal Distance
Icon:
Number of DOF consumed: 1
The horizontal distance fixes a point in one direction, thus consuming 1 DOF.
The horizontal distance constraint can either fix the horizontal distance between two points
or it can fix the x-coordinate.

• Applied to two points it fixes the horizontal distance between the points, independent
from their position in the plane:

−→

It is possible but in this case hardly sensible to set it to a negative value.

• Applied to a line is the same as applying it to the endpoints of the line.

73
• Applied to a single point it sets the x-coordinate to the origin. If the value is negative,
the point is left of the origin.

−→

Avoid horizontal distances of zero length


It is possible to align things vertically by applying a horizontal distance of 0. Although there
is no solver message warning you should avoid this. Use a vertical constraint instead.
For one it is recommended to prefer geometric constraints, second it keeps your sketch cleaner
without the measure.

31 Vertical Distance
Icon:
Number of DOF consumed: 1
The vertical distance fixes a point in one direction, thus consuming 1 DOF.
Applied to a single point it fixes the vertical distance to the origin, applied to two points it
fixes the vertical distance between them.
Everything which has been said about the horizontal distance holds for the vertical distance
as well, if you exchange ”horizontal” and ”vertical”.

32 Lock
Icon:
Number of DOF consumed: 2 per point
The lock constraint creates a horizontal and a vertical distance constraint for each point
involved which sums up to 2 DOF per point.
It is a shortcut to create horizontal and a vertical constraints without user interaction. Like
the block constraint it can be intriguing to use this in order to arrive faster at a fully con-
strained sketch, but you should avoid this and apply as many geometric constraints as possible
before.
It can be sensible to use the lock constraint if you have created the sketch with grid snap
enabled (see section 2 on page 10) and you want to fix the points exactly in these positions.

74
The lock constraint is applied to a selection of points. Depending on the number of selected
points the behaviour is slightly different:

One point selected The lock constraint creates a horizontal and a vertical distance con-
straint to the origin.

Two points selected A horizontal and a vertical distance constraint between these two
points is created. (This is in fact a special variant of the following case.)

Three or more points selected A horizontal and a vertical distance constraint between
each of these points and the last point is created.
The behaviour is as if you had created all of these lock constraints separately, which
you can see if you use the undo function.

33 Length

Icon:
Number of DOF consumed: 1
Consider a line with one point fixed, it has two DOF remaining. Applying a length constraint
reduces this to 1 DOF (which can be consumed by a horizontal or vertical distance). Thus
the length constraint consumes 1 DOF.
The length constraint comes in three different variants, two of them being rather similar

Line Length. It can fix the length of a line, as we have seen in section 6 on page 20.

−→

Distance between points. Select two arbitrary points and fix the distance between them:

−→

75
Distance from point to line. If you select a line and a point, this constraint fixes the
orthogonal distance between line and point, i. e. the distance between the point and
its projection on the line. Thus it fixes the minimal distance between line and point.
As we have seen before, the projection point can lie on the infinite prolongation of the
line.

−→

Warning: As mentioned in the section 6 on page 20 about lines you should not use this
constraint for horizontal or vertical lines—unless you intend to change the angle of the element
in Sketcher later (for an example of this consider turning a slot as in section 12 on page 36).
Use the specialized constraints horizontal distance or vertical distance instead. That makes
it easier for the solver to find a solution; see section 36 on page 79 for details.

34 Radius and Diameter


Icons:

Number of DOF consumed: 1


The radius or diameter constraint fixes one of the three DOF of a circle. (Two remain for
the position of the center.)
Application is straight forward: select a circle in the Sketch and apply the radius constraint
where you can input the value. If you want to use diameters in your sketch instead of radius,
open the icon drop down menu and select the diameter. It will stay in that mode until you
switch it back or quit and restart FreeCAD.

35 Angle

Icon:
Number of DOF consumed: 1
Like vertical or horizontal constraints the angle fixes the orientation of a line in the plane
and consumes 1 DOF.
After creating a line segment, whichever of the two endpoints was created first is usually
irrevelant. However, it makes a difference here because applying the angle constraint on two

76
lines that appear identical will result in two different angles depending on which endpoint of
a particular line segment was created first. When applying an angle constraint, the two lines
are treated as if they are rays.
There are different modes for this constraint:

Single Line mode. Select a line and apply the angle constraint. This fixes the angle be-
tween the line and the X-axis.
While it is usually irrelevant in which way you create a line, here it is: for two seemingly
identical lines you can get different angles.

Exercise 32 Create two approximately parallel lines, one from lower left to upper right
and another vice versa from upper right to lower left.
Select the first line and apply an angle constraint.
Select the second line and apply an angle constraint.

Line-Line mode. The most frequently used variant is to select two lines and define with
the angle constraint the angle between them.
Again it depends on the orientation of the angle where it is actually applied:

Line-Point-Line mode. If you select two lines and an additional point before applying an
angle constraint, this point will become the vertex of the angle and the lines are the
rays. To achieve this one or two point-on-object constraints are generated in addition
to the angle between the lines. This assures that the vertex lies in fact on both lines.

Exercise 33 Create a sketch with two lines and a point according to the following
image.

77
Select both lines and the point and apply an angle constraint with an angle of 30◦

−→

Warning: Applying this constraint consumes usually 3 DOF, one for the angle and
two for the point-on-object constraints. If one of the points happens to be the endpoint
of one of the lines, only 2 DOF are consumed.

Single Arc mode If you select only an arc line and apply an angle constraint, the angle
between one endpoint of the arc, the center and the other endpoint is fixed. For a given
radius this fixes the arc length. The following exercise creates a 3/4 circle:

Exercise 34 Create an arc. Select it and apply an angle of 270◦ .

−→

Remark on arc length: This kind of angle constraint can be used to calculate the
length of the arc in an expression: given the radius r and the angle α the length of the
arc line l is given by

α
l =2∗π∗r∗
360◦

or vice versa if l is given you can set the angle to yield the same length for the arc by

l ∗ 360◦
α=
2πr
78
Arc-Arc mode. Similar to Line-Point-Line mode you can combine two arcs and a point or
an arc, a line, and a point. This means that Line-Point-Line mode can be viewed as a
special form of this more general mode.

Exercise 35 Create a sketch with two arcs which are connected with a coincidence
constraint. Let the arcs cross at an angle of 60◦ . In the following image the vertex of
the angle is an endpoint of one of the arcs.

−→

Warning: Applying this constraint can consumes 1, 2 or 3 DOF, because additional


constraints can be created. It consumes 1 DOF for the angle if the arcs are already
connected by a coincidence constraint. No additional constraint is created.
It consumes 2 DOF by creating an additional point-on-object constraint, if they are
not connected but the point selected is one of the endpoints of the arc.
It consumes 3 DOF by creating two additional point-on-object constraints, if the point
selected is none of the endpoints of the arcs.

Dos and Don’ts with Angles

• Don’t use angles with multiples of 90◦ ; use geometric constraints instead.

– For an angle of 90◦ or 270◦ use the perpendicular constraint.


– For an angle of 180◦ use the tangent constraint.

• However, if you have a flipping sketch as shown in section 19.2 on page 48 you can
improve robustness, due to the fact that the angle constraint respects the direction of
the lines as if they are rays.

36 Further Dos and Don’ts with Constraints


Now that you know about the different constraints, you should not only aim at fully con-
strained sketches, you should create good fully constrained sketches. Some advice was already
given for some of the constraints above, here are some additional recommendations.
The following recommendations are based on recommendations given by the developer who
first coded Sketcher workbench (FreeCAD forum user logari81) and other power users.
There are several things to consider. There is what I would like to call the external or user’s
view: Is the sketch easy to understand and easy to maintain?

79
The other side to consider is the internal view: Which constraints are friendly to the solver,
i. e. which lead to reliable solutions. The solver does not solve its internal equation system
algebraically, but numerically. That means a sketch is fully constrained if the deviations are
very very small. Nevertheless there are rounding errors due to the finite precision, and in
rare cases these can lead to difficulties in later modelling steps.

Prefer geometric constraints over measures

It is recommended to prefer geometric constraints over measures with numerical values; the
latter are crowding the view and make the sketch less flexible.
Even more important than these convenience properties is the fact that geometric constraints
are better suited to transport what I call the intrinsic idea of a sketch. Have a look at this
sketch:

The sketch is fully constrained and you can derive from the dimensions given, that the line
at the top is horizontal, and that arc and line are tangent. But if that is what is really
important, then the sketch should reflect it:

Beyond the improved clarity there are features such as Sweep, which tend to fail on sketches
which don’t have set tangencies explicitely using tangency constraints.
A very strong indicator for dimensions to be replaced by geometric constraints is the repitition
of identical values as the 10 mm in the example above.

80
Don’t use dimensions of length 0

This is a special case of the previous recommendation; it is mentioned explicitely because


they are used rather frequently by inexpierienced users. Such constraints should always be
replaced by geometric constraints.

Preferred solver friendly constraints

• Coincidence

• Horizontal and vertical constraint.

• Point to Point tangency.

• Point on line

• Horizontal and vertical length.

Constraints for subordinate use

It is by no way wrong to use these constraints. But you should not use them, if you can use
one of the preferred constraints instead.

• Length

• Edge/Edge Tangency

• Symmetry

Don’t make your sketch too complicated!

Instead of putting everything possible into one sketch, you should consider to split it into
several sketches. As an example take a sketch with some holes and cutouts and a complicated
outline, which you want to pad. Instead of modeling all in one sketch you can model the
outline in the first sketch, pad it, model the cutouts in another sketch and make a pocket.
As a rule of thumb it is recommended (thanks Normand!) to use not more than 100 con-
straints in a sketch to keep solver time at a reasonable level.

37 Driven dimensions
Sometimes it is interesting to see the value of a certain distance or an angle without setting
it. For this purpose you can use driven dimensions. This can be more than just interesting
if you want to use such values in an expression outside of the sketch.

Exercise 36 We will show how to get the square root of 2, which is known to be the diagonal
length of a square with side length 1.

81
• Draw a square with side length 1.

• Select diagonal points and start as if you want to create a length dimension. The
sketch was fully constrained, so the solver shows an error message. But if you check the
Reference box, the error will vanish and the dimension will be shown in blue instead of
red.

Confirm and you will permanently see the length of the diagonal even if you change
the length of the sides.

There are three ways to create a driven dimension:

• You can do it in the way described in the previous exercise.

• You can select an existing dimension and click the toggle . This can also be used
if you want to switch from a driven constraint to a real (”driving”) constraint.

• Without having anything selected click the same toggle icon . The dimensional

constraints icons will turn blue and

all dimensions created in this mode will be driven constraints.

82
It is well known that the angle between two adjacent lines in a square is 90◦ . But how about
a pentagon?

Exercise 37 Create a regular pentagon with an outer radius of 10. Find the angle between
two adjacent edges and find the radius of the incircle.

Solution: The angle is 108◦ and the radius of the incircle is approximately 8.090.

38 External Geometry

Icon:
Number of DOF added: 0
External geometry reuses geometry defined elsewhere thus adding no DOF to a sketch.
On the one hand external geometry can reference elements of other objects, such as edges or
vertices. I don’t recommend newcomers to use this kind of external geometry, because the
resulting models are fragile concerning topological naming issues.
On the other hand external geometry reuses elements from previously defined sketches. This
is what we will use here.

83
Exercise 38 Given a block of the shape below we want to cut a strip off at two ends of one
of the sides.

−→

• Preparations: Create a block as shown in the left image. Place it so that the face in
front lies in one of the principal planes.
I have placed the sketch of mine in the XZ plane and have checked the ”Reverse” box
of the pad.

• Create a new sketch in the same plane as the front of the block.

• Don’t close the still empty sketch. In the Combo view switch from Task tab to Model
tab, in order to view the history tree.

• Make the pad invisible and the sketch visible, the tree should look like this:

84
The sketch named ”SketchBlock” in the above picture is used to create the Pad named
”PadBlock”. The sketch we actually are still editing is Sketch009. In your model it
will probably be named Sketch001.

• Switch back from Model tab to Tasks tab, now showing the well known Sketcher panel
again.

• In 3D view you can see the SketchBlock’s sketch. The lines are slighly thinner than
those in the current sketch, you cannot change the SketchBlock geometry.

• Select the external geometry tool .

• Select the upper line, it will turn magenta.

You could now directly select more elements, which is not necessary here. Instead of
selecting the line, you could have selected the endpoints only.

• Model the strips. Please note, that the strips cover more than they have to remove.

85
– Both strips have the same width of 5 mm.
– The right side of the right strip is fixed with the point-on-object constraint using
the endpoint of the external geometry.
– The bottom line of the right strip is fixed by a point-on-object constraint on the
X-axis.
– The left upper line is horizontal
– both upper lines line are aligned with a tangency constraint.

• Close the Sketcher and apply the pocket with a depth of 5 mm.

Identification of external geometry

The list of elements as described in section 3 on pages 12–14 contains all geometric elements,
including external geometry. These external geometry elements are always last in the list.
The dots at the end of the icons in the list have magenta color – the same color as used
for the external elements in 3D view. In the image you see that the last three elements are
references to external geometry: a line, an arc, and another line.

Below the list you can check ”Extended Naming”, which names the elements bein external
and shows where they are linked to.

86
Part IV

Creating Objects Based on Sketches


To be written

39 Sketches for Pads and Pockets


this section is not ready yet!
Sketches are not always, but most frequently used to create an object or a feature, such as
an Extrude in Part workbench or Pads and Pockets in PartDesign.
However, not all sketches are suitable for this, especially in PartDesign workbench, where you
can create only solids. Sketches to be suitable for creating features—additive or subtractive—
have to meet certain conditions. These conditions do not apply to construction geometry
though.

Sketches must be closed. Every geometric element—line, arc, B-spline—is at its end con-
nected to exactly one other geometric element. ”Exactly one” having the meaning that
neither zero, nor two or more elements can be connected at the ends.
”Connected” has the meaning, that the points have indeed to be connected by an ap-
propriate constraint, where most commonly used is of course the coincidence constraint,
but point-to-point tangent or normal constraints can be used as well.

Sketches must not have self intersections. Sketches must not have crossing lines or T-
joins. If there are such things it is no longer clear what is inside and what is outside of
an object created with such a sketch.
ToDo: add image with nested circles ToDo: add image with nested and crossing lines

Sketches can have one nesting level, but not more. It is allowed to have e.g. two con-
centric circles, which can be used to create a tube.
Althoug it could be sensible to have more nesting levels—three concentric circles could
create a tube with an additional cylinder in its center—this is not allowed in FreeCAD.

40 Use Symmetry!

41 Placement and AttachmentOffset

42 Validate sketches

87
DOF overview
Elements Constraints
Element Icon DOF Constraint Icon DOF
added consumed
Line 4 Coincidence 2
PointOnObject 1
Circle 3
Vertical 1
Arc 5 Horizontal 1
Polyline - Parallel 1

Rectangle 4 Perpendicular line/line 1


Perpendicular point/line 2
Triangle 4 Perpendicular point/point 3
Tangent (curve/curve) 1
Square 4 Tangent (point/curve,line/line) 2
Tangent (point/point) 3
Pentagon 4
Equality 1
Hexagon 4 Symmetry 2
Heptagon 4 Block 1-arbitrary

Octagon 4 Lock 2 per point


Horizontal Distance 1
RegularPolygon 4
Vertical Distance 1
Slot 4
Length 1
Point 2 Radius 1
B-spline open 3*N Diameter 1

B-spline closed 3*N Angle 1

88

You might also like