With the Sketcher Workbench 2D sketches intended for use in other workbenches can be created. 2D sketches are the starting point for many CAD models. They typically define the profiles and paths for operations to create 3D shapes. A model may depend on several sketches for its final shape.
Together with boolean operations defined in the Part Workbench, the Sketcher Workbench, or "The Sketcher" for short, forms the basis of the constructive solid geometry (CSG) method of building solids. Together with
PartDesign Workbench operations, it also forms the basis of the feature editing methodology of creating solids. But many other workbenches use sketches as well.
The Sketcher workbench features constraints, allowing 2D shapes to follow precise geometrical definitions in terms of length, angles, and relationships (horizontality, verticality, perpendicularity, etc.). A constraint solver calculates the constrained-extent of 2D geometry and allows interactive exploration of the degrees-of-freedom of the sketch.
The Sketcher is not intended for producing 2D blueprints. Once sketches are used to generate a solid feature, they are automatically hidden and constraints are only visible in Sketch edit mode. If you only need to produce 2D views for print, and don't want to create 3D models, check out the Draft workbench.
A fully constrained sketch
Constraints are used to limit the degrees of freedom of an object. For example, a line without constraints has 4 degrees of freedom (abbreviated as "DoF"): it can be moved horizontally or vertically, it can be stretched, and it can be rotated.
Applying a horizontal or vertical constraint, or an angle constraint (relative to another line or to one of the axes), will limit its capacity to rotate, thus leaving it with 3 degrees of freedom. Locking one of its points in relation to the origin will remove another 2 degrees of freedom. And applying a distance dimension will remove the last degree of freedom. The line is then considered fully constrained.
Objects can be constrained in relation to one another. Two lines can be joined through one of their points with a coincident constraint. An angle can be set between them, or they can be set perpendicular. A line can be tangent to an arc or a circle, and so on. A Sketch may have a number of different solutions, and making it fully constrained can mean that just one of these possible solutions has been reached based on the applied constraints. See also: Flipping.
There are two kinds of constraints: geometric and dimensional. They are detailed in the Tools section below.
introduced in 1.1: The label of dimensional constraints in the sketch identifies their state: reference dimensions are enclosed in parentheses, dimensions controlled by an expression have a (ƒ𝑥) suffix, and deactivated dimensions are struck through.
When a driving dimensional constraint is created, and if the Ask for value after creating a dimensional constraint preference is selected (default), a dialog opens to edit its value.
You can enter a numerical value or an expression, and it is possible to name the constraint to facilitate its use in other expressions. Check the Reference checkbox to switch the constrain to reference mode. introduced in 26.3: For radius and diameter dimensions it is possible to switch between one and the other. Note that with the Dimension tool this can also be accomplished with the M key.
introduced in 26.3: When a dimensional constraint whose value is controlled by an expression, is hovered in the sketch or the Constraints section of the Sketcher Dialog, and no sketcher tool is active, a tooltip displays that expression.
To edit the value of an existing dimensional constraint do one of the following:
Dimensional constraints can be repositioned in the 3D View by dragging. Hold down the left mouse button over the constraint value and move the mouse. The symbols of geometric constraints are positioned automatically and cannot be moved.
Dimension and constraint tools running in Continue Mode can directly reference edges and vertices outside the sketch. If not yet available, projected external geometry is created automatically, and this is used as the dimension or constraint operand. The external geometry is created as construction geometry. The referenced object(s) must belong to the same geometric parent (for example the same Std Part or PartDesign Body) as the sketch, or sketch and object(s) must all be in the global space.
When a sketch has only one dimension that defines its scale, entering a new numerical value for that dimension can scale the entire sketch about its origin. This preserves the overall proportions when you first size a roughly drawn sketch. For example, changing a rectangle's only length dimension from 10 mm to 20 mm doubles both its width and height. Angle constraints do not count as scale-defining dimensions. The view is adjusted along with the geometry, so the sketch can appear to keep the same size on screen. The Scale upon first constraint preference controls this behavior.
To create a sketch that can be used as a profile for generating solids certain rules must be followed:
Invalid sketches:
1. Open contour (free endpoints highlighted by the Validate Sketch tool)
2. Intersecting contours
3. Duplicate edges (endpoints of overlapping edges highlighted by the Validate Sketch tool)
4. T-connections
These rules do not apply to construction geometry (default color blue), which is not shown outside edit mode, or if the sketch is used for a different purpose. Depending on the workbench and the tool that will use the profile sketch, additional restrictions may apply.
If the DataMake Internals property of a sketch is set to true internal faces are generated based on the edges in the sketch. These faces can be selected as closed profiles for operations. Intersecting contours and T-connections are allowed, they just result in additional faces.
The Sketcher Workbench tools are located in the Sketch menu and/or several toolbars. Almost all Sketcher toolbars are only displayed while a sketch is in edit mode. The only exception is the Sketcher toolbar which is only displayed if no sketch is in edit mode.
Some tools are also available from the 3D View context menu while a sketch is in edit mode, or from the context menus of the Sketcher Dialog.
If a sketch is in edit mode the Structure toolbar is hidden as none of its tools can then be used.
These are tools for creating objects.
These are tools for creating constraints. Some constraints require the use of helper constraints.
The Sketcher Workbench has several drawing aids and other features that can help when creating geometry and applying constraints.
There are two continue modes: Geometry creation "Continue Mode" and Constraint creation "Continue Mode". If these are checked (default) in the preferences, related tools will restart after finishing. To exit a continuous tool press Esc or the right mouse button. This must be repeated if a continuous geometry tool has already received input. You can also exit a continuous tool by starting another geometry or constraint creation tool. Note that pressing Esc if no tool is active will exit sketch edit mode. Uncheck the Esc key can leave sketch edit mode preference if you often inadvertently press Esc too many times.
In sketches that have Auto constraints checked (default) several constraints are applied automatically when creating geometry or (introduced in 26.3) dragging existing points. The icon of a proposed automatic constraint is shown next to the cursor when it is placed correctly. Left-clicking, or ending the drag operation by releasing the Left mouse button, will then apply that constraint. This is a per-sketch setting that can be changed in the Sketcher Dialog or by changing the ViewAutoconstraints property of the sketch.
There is a fine-tuning parameter to control the auto constraint delay when dragging geometry.
The following constraints are applied automatically:
To create auto constraints along extended arcs circular helpers can be shown.
Lines are automatically extended with helper lines if the cursor is positioned correctly. This allows creating point-on-object auto constraints along the line.
Using a directional helper line to create a perpendicular auto constraint
If the Show directional autoconstraint helpers preference is selected (default), tangential, or perpendicular and parallel helper lines referencing a target edge can be shown while using the Polyline tool (only when creating line segments) and
Line tool.
Note that straight target edges that are horizontal or vertical are ignored.
It is possible to snap to grid lines and grid intersection, and to snap to edges of geometry and midpoints of lines and arcs, and to certain angles. Please note that snapping does not produce constraints in and of itself. For example, only if Auto constraints is switched on will snapping to an edge produce a point-on-object constraint. But just picking a point on the edge would then have the same result.
Depending on the selected option in the preferences only the dimensional On-View-Parameters or both the dimensional and the positional On-View-Parameters can be enabled. Positional parameters allow the input of exact coordinates, for example the center of a circle, or the start point of a line. Dimensional parameters allow the input of exact dimensions, for example the radius of a circle, or the length and angle of a line. On-View-Parameters are not available for all tools.
Determining the center point of a circle with the positional parameters enabled
Determining the radius of a circle with the dimensional parameters enabled
If values are entered and confirmed by pressing Enter or Tab, related constraints are added automatically. If two parameters are displayed at the same time, for example the X- and Y-coordinate of a point, it is possible to enter one value and pick a point to define the other. Depending on the object additional constraints may be required to fully constrain it. Constraints resulting from On-View-Parameters take precedence over those that may result from Auto constraints.
introduced in 26.3 If an OVP input has the focus you can hold down Alt to send key strokes to the 3D View instead.
Arc created by entering all On-View-Parameters with resulting automatically created constraints
If the Show coordinates next to the cursor while editing preference is checked (default), the parameters of the current geometry tool (coordinates, radius, or length and angle) are displayed next to the cursor. This is deactivated while On-View-Parameters are shown.
While a sketch is in edit mode several selection methods can be used. introduced in 26.3: For all methods selection filters are taken into account.
As elsewhere in FreeCAD, an element can be selected in the 3D View with a single left mouse click. But there is no need to hold down the Ctrl key when selecting multiple elements. Holding down that key is possible though and has the advantage that you can miss-click without losing the selection. Edges, points and constraints can be selected in this manner.
Box selection in the 3D View works without using Std BoxSelection or Std BoxElementSelection:
You can box-select edges and points, constraints cannot be box-selected.
Double-clicking an edge in the 3D View will select all edges directly and indirectly connected with that edge via endpoints. There is no need for the edges to be connected with coincident constraints, endpoints need only have the same coordinates.
Edges and points can also be selected from the Elements section of the Sketcher Dialog, and constraints from the Constraints section of that dialog.
To select everything within a sketch, use the standard keyboard shortcut Ctrl+A or the Edit → Select All option from the menu.
introduced in 1.1: To drag several elements together, select them using any selection method, hold down the left mouse button over one of the selected elements, move the mouse, then release the button to finish the drag. Existing constraints remain in effect and can limit or prevent the movement. Fully constrained geometry cannot be dragged. Any selected external geometry is excluded from the drag.
The standard keyboard shortcuts, Ctrl+C, Ctrl+X and Ctrl+V, can be used to copy, cut and paste selected Sketcher geometry including related constraints. But these tools are also available from the Sketch → Sketcher Tools menu. They can be used within the same sketch but also between different sketches or separate instances of FreeCAD. Since the data is copied to the clipboard in the form of Python code, it can be used in other ways too (e.g. shared on the forum).
Geometry created by External Projection and External Intersection can be used with Offset, Move / Array Transform, Rotate / Polar Transform, Scale and Mirror. Both external construction geometry and external defining geometry are accepted.
If the operation changes or removes the original geometry, its external reference is removed from the sketch. Removing a face reference removes all external edges created from that face. The source object remains unchanged. To retain a reference alongside the result, use a tool option that keeps the originals.
Every CAD user develops their own way of working over time, but there are some useful general principles to follow.
The phenomenon that a fully constrained sketch, usually after a major change to one of its dimensions, reaches an unintended new state is known as "flipping". In the example below, changing one dimension completely changes the shape of the sketch. Note that the sketch with the new shape is still fully constrained.
Original sketch (left), and the same sketch after increasing the 20mm value to 1000mm (right)
This is not always practical, but changing dimension values in smaller increments can work.
The LevenbergMarquardt solver, which is not the default solver, is known to be less prone to flipping. See Sketcher Dialog for more information.
Using horizontal and vertical dimensions instead of distance dimensions or equal constraints can prevent flipping. Points constrained by these dimensions will only switch places if the sign of their value is changed. In the image above the added (orange) dimensional constraints are linked to the original dimensions via expressions.
Using angle dimensions instead of horizontal and vertical constraints can also work. The angle between edges constrained by angle dimensions will not change. 180° will not become 0°, 90° will not become 270°, etc. In the image all horizontal and vertical constraints have been replaced, but just replacing two is already effective here.
The Sketcher scripting page contains examples on how to create constraints from Python scripts.
For some ideas of what can be achieved with Sketcher tools, have a look at: Sketcher Examples.