Sketcher Workbench
Introduction
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
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 dimension constraint 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 the coincident point 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 complex Sketch with multiple objects 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.
There are two kinds of constraints: geometric and dimensional. They are detailed in the Tools section below.
Edit constraints
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. You can also check the Reference checkbox to switch the constrain to reference mode.
To edit the value of an existing dimensional constraint do one of the following:
- Double-click the constraint value in the 3D view.
- Double-click the constraint in the Sketcher Dialog.
- Right-click the constraint in the Sketcher Dialog and select the Change value option from the context menu.
Reposition constraints
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.
Profile sketches
To create a sketch that can be used as a profile for generating solids certain rules must be followed:
- The sketch must contain only closed contours. Gaps between endpoints, however small, are not allowed.
- Contours can be nested, to create voids, but should not self-intersect or intersect other contours.
- Contours cannot share edges with other contours. Duplicate edges must be avoided.
- T-connections, that is more than two edges sharing a common point, or a point touching an edge, are not allowed.
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.
Drawing aids
The Sketcher Workbench has several drawing aids and other features that can help when creating geometry and applying constraints.
Continue modes
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 can leave sketch edit mode preference if you often inadvertently press Esc too many times.
Auto constraints
In sketches that have Auto constraints checked (default) several constraints are applied automatically. The icon of a proposed automatic constraint is shown next to the cursor when it is placed correctly. Left-Clicking 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.
The following constraints are applied automatically:
- Coincident
- Point on object
- Horizontal
- Vertical
- Tangent
- introduced in version 1.0: Symmetric (line midpoint)
Snapping
It is possible to snap to grid lines and grid intersection, 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.
On-View-Parameters
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.
Arc created by entering all On-View-Parameters with resulting automatically created constraints
Coordinate display
If the Show coordinates beside 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.
Selection methods
While a sketch is in edit mode the following selection methods can be used:
3D view element selection
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.
3D view box selection
Box selection in the 3D view works without using Std BoxSelection or Std BoxElementSelection:
- Make sure that no tool is active.
- Do one of the following:
- Click in an empty area and drag a rectangle from left to right to select elements that lie completely inside the rectangle.
- Click in an empty area and drag a rectangle from right to left to also select elements that touch or cross the rectangle.
You can box-select edges and points, constraints cannot be box-selected.
3D view connected geometry selection
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.
Sketcher Dialog selection
Edges and points can also be selected from the Elements section of the Sketcher Dialog, and constraints from the Constraints section of that dialog.
Copy, cut and paste
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).
Tools
The Sketcher Workbench tools are located in the Sketch menu and/or several toolbars. introduced in version 0.21: 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.
introduced in version 0.21: If a sketch is in edit mode the Structure toolbar is hidden as none of its tools can then be used.
General
Sketcher toolbar
- Create sketch: Creates a new sketch and opens the Sketcher Dialog to edit it.
- Edit sketch: Opens the Sketcher Dialog to edit an existing sketch.
- Attach sketch: Attaches a sketch to selected geometry.
- Reorient sketch: Places a sketch on one of the main planes with an optional offset. It can also be used to detach a sketch.
- Validate sketch: Can analyze and repair a sketch that is no longer editable or has invalid constraints, or add missing coincident constraints.
- Merge sketches: Merges two or more sketches.
- Mirror sketch: Mirrors sketches across their X axis, Y axis, or origin.
Sketcher Edit Mode toolbar
- Leave sketch: Finishes sketch edit mode and closes the Sketcher Dialog.
- View sketch: Aligns the 3D view with the sketch.
- View section: Toggles a temporary section plane that hides any objects and parts of objects in front of the sketch plane.
Sketcher edit tools toolbar
- Toggle grid: Toggles the grid in the sketch currently being edited. Settings can be changed in the related menu. introduced in version 0.21
- Toggle snap: Toggles snapping in all sketches. Settings can be changed in the related menu. introduced in version 0.21
- Configure rendering order: The rendering order of all sketches can be changed in the related menu. introduced in version 0.21
Other
- Stop operation: Stops any currently running geometry or constraint creation tool.
Sketcher geometries
These are tools for creating objects.
- Point: Creates a point.
- Polyline: Creates a series of line and arc segments connected by their endpoints. The tool has several modes.
- Line: Creates a line. introduced in version 1.0: The tool has three modes.
- Arc by center: Creates an arc by its center and its endpoints. introduced in version 1.0: Or by its endpoints and a point along the arc.
- Arc by 3 points: Creates an arc by its endpoints and a point along the arc. introduced in version 1.0: This is the same tool as Arc by center but with a different initial mode.
- Arc of ellipse: Creates an arc of ellipse.
- Arc of hyperbola: Creates an arc of hyperbola.
- Arc of parabola: Creates an arc of parabola.
- Circle by center: Creates a circle by its center and a point along the circle. introduced in version 1.0: Or by three points along the circle.
- Circle by 3 points: Creates a circle by three points along the circle. introduced in version 1.0: This is the same tool as Circle by center but with a different initial mode.
- Ellipse by center: Creates an ellipse by its center, an endpoint of one of its axes, and a point along the ellipse. introduced in version 1.0: Or by both endpoints of one of its axes and a point along the ellipse.
- Ellipse by 3 points: Creates an ellipse by the endpoints of one of its axes and a point along the ellipse. introduced in version 1.0: This is the same tool as Ellipse by center but with a different initial mode.
- Rectangle: Creates a rectangle. introduced in version 1.0: The tool has four modes. Rounded corners and creating an offset copy are optional features.
- Centered rectangle: Creates a centered rectangle. introduced in version 1.0: This is the same tool as Rectangle but with a different initial mode.
- Rounded rectangle: Creates a rounded rectangle. Idem.
- Triangle: creates an equilateral triangle. introduced in version 1.0: This is the same tool as Regular polygon but with the number of sides preset to a specif value.
- Square: Creates a square. Idem.
- Pentagon: Creates a pentagon. Idem.
- Hexagon: Creates a hexagon. Idem.
- Heptagon: Creates a heptagon. Idem.
- Octagon: Creates an octagon. Idem.
- Regular polygon: Creates a regular polygon. The number of sides can be specified.
- Slot: Creates a slot.
- Arc slot: Creates an arc slot. introduced in version 1.0
- B-spline by control points: Creates a B-spline curve by control points. introduced in version 1.0: Or by knot points.
- Periodic B-spline by control points: Creates a periodic (closed) B-spline curve by control points. introduced in version 1.0: This is the same tool as B-spline by control points but with a different initial mode.
- B-spline by knots: Creates a B-spline curve by knot points. Idem.
- Periodic B-spline by knots: Creates a periodic (closed) B-spline curve by knot points. Idem.
- Toggle construction geometry: Either toggles the geometry creation tools to/from construction mode, or toggles selected geometry to/from construction geometry.
Sketcher constraints
These are tools for creating constraints. Some constraints require the use of Helper constraints.
- Dimension: Is the context-sensitive constraint tool of the Sketcher Workbench. Based on the current selection, it offers appropriate dimensional constraints, but also geometric constraints. introduced in version 1.0
- Horizontal distance: Fixes the horizontal distance between two points or the endpoints of a line. If a single point is pre-selected, the distance is relative to the origin of the sketch.
- Vertical distance: Fixes the vertical distance between two points or the endpoints of a line. If a single point is pre-selected, the distance is relative to the origin of the sketch.
- Distance: Fixes the length of a line, the distance between two points, the perpendicular distance between a point and a line; or, introduced in version 0.21, the distance between the edges of two circles or arcs, or between the edge of a circle or arc and a line; or, introduced in version 1.0, the length of an arc.
- Auto radius/diameter: Fixes the radius of arcs and B-spline weight circles, and the diameter of circles.
- Radius: Fixes the radius of circles, arcs and B-spline weight circles.
- Diameter: Fixes the diameter of circles and arcs.
- Angle: Fixes the angle between two edges, the angle of a line with the horizontal axis of the sketch, or the aperture angle of a circular arc.
- Lock: Applies Horizontal distance and Vertical distance constraints to points. If a single point is selected the constraints reference the origin of the sketch. If two or more points are selected the constraints reference the last point in the selection.
- Coincident (unified): Creates a coincident constraint between points, fixes points on edges or axes, or creates a concentric constraint. It combines the Coincident and Point on object tools. introduced in version 1.0
- Coincident: Creates a coincident constraint between points, or a concentric constraint.
- Point on object: Fixes points on edges or axes.
- Horizontal/vertical: Constrains lines or pairs of points to be horizontal or vertical, whichever is closest to the current alignment. It combines the Horizontal and Vertical tools. introduced in version 1.0
- Horizontal: Constrains lines or pairs of points to be horizontal.
- Vertical: Constrains lines or pairs of points to be vertical.
- Parallel: Constrains lines to be parallel.
- Perpendicular: Constrains two lines to be perpendicular, or two edges, or an edge and an axis, to be perpendicular at their intersection. The constraint can also connect two edges, forcing them to be perpendicular at the joint.
- Tangent or collinear: Constrains two edges, or an edge and an axis, to be tangent. The constraint can also connect two edges, forcing them to be tangent at the joint. If two lines are selected they are made collinear.
- Equal: Constrains edges to have an equal length (lines) or curvature (other edges except B-splines).
- Symmetric: Constrains two points to be symmetrical around a line or axis, or around a third point.
- Block: Blocks edges in place with a single constraint. It is mainly intended for B-splines.
- Refraction (Snell's law): Constrains two lines to follow the law of refraction of light as it penetrates through an interface.
- Toggle driving/reference constraint: Toggles the dimensional constraint creation tools between driving and reference mode, or toggles selected dimensional constraints between those modes.
- Activate/deactivate constraint: Activates or deactivates selected constraints.
Sketcher tools
- Fillet: Creates a fillet between two non-parallel edges. introduced in version 1.0: The tool can also create a chamfer.
- Chamfer: creates a chamfer between two non-parallel edges. This is the same tool as Fillet but with a different initial mode. introduced in version 1.0
- Trim: Trims an edge at the nearest intersections with other edges.
- Split: Splits an edge while transferring most constraints.
- Extend: Extends or shortens a line or an arc to an arbitrary location, or to a target edge or point.
- External geometry: Projects edges and/or vertices belonging to objects outside the sketch onto the sketch plane.
- Carbon copy: Copies all geometry and constraints from another sketch into the active sketch.
- Select origin: Selects the origin of the sketch.
- Select horizontal axis: Selects the horizontal axis of the sketch.
- Select vertical axis: Selects the vertical axis of the sketch.
- Array transform: Moves or optionally creates copies of selected elements. introduced in version 1.0
- Polar transform: Rotates or optionally creates rotated copies of selected elements. introduced in version 1.0
- Scale transform: Scales or optionally creates scaled copies of selected elements. introduced in version 1.0
- Offset geometry: Creates equidistant edges around selected edges. introduced in version 1.0
- Symmetry: Creates mirrored copies of selected elements.
- Remove axes alignment: Removes the axes alignment of selected edges by replacing Horizontal and Vertical constraints with Parallel and Perpendicular constraints.
- Delete all geometry: Deletes all geometry and all constraints from the sketch.
- Delete all constraints: Deletes all constraints from the sketch.
- Copy in Sketcher: See Copy, cut and paste.
- Cut in Sketcher: See Copy, cut and paste.
- Paste in Sketcher: See Copy, cut and paste.
Sketcher B-spline tools
- Convert geometry to B-spline: Converts edges to B-splines.
- Increase B-spline degree: Increases the degree (order) of B-splines.
- Decrease B-spline degree: Decreases the degree (order) of B-splines.
- Increase knot multiplicity: Increases the multiplicity of a B-spline knot.
- Decrease knot multiplicity: Decreases the multiplicity of a B-spline knot.
- Insert knot: Inserts a knot into a B-spline or increases the multiplicity of an existing knot.
- Join curves: Creates a B-spline by joining two existing B-splines or other edges. introduced in version 0.21
Sketcher visual
- Select unconstrained DoF: Selects the not fully constrained elements in the sketch.
- Select associated constraints: Selects the constraints associated with sketch elements.
- Select associated geometry: Selects the sketch elements associated with constraints.
- Select redundant constraints: Selects the redundant constraints in the sketch.
- Select conflicting constraints: Selects the conflicting constraints in the sketch.
- Show/hide circular helper for arcs: Shows or hides the circular helpers (underlying virtual circles) for arcs in all sketches. introduced in version 1.0
- Show/hide B-spline degree: Shows or hides the B-spline degree in all sketches.
- Show/hide B-spline control polygon: Shows or hides the B-spline control polygon in all sketches.
- Show/hide B-spline curvature comb: Shows or hides the B-spline curvature comb in all sketches.
- Show/hide B-spline knot multiplicity: Shows or hides the B-spline knot multiplicity in all sketches.
- Show/hide B-spline control point weight: Shows or hides the B-spline control point weight in all sketches.
- Show/hide internal geometry: Deletes the internal geometry of elements, or recreates missing internal geometry.
- Switch virtual space: (un)hides constraints or switches the visible virtual space.
Obsolete tools
- Clone: Clones a Sketcher element. Not available in version 1.0 and above.
- Close shape: Creates a closed shape by applying coincident constraints to endpoints. Not available in version 0.21 and above.
- Corner-preserving fillet: Creates a fillet between two non-parallel lines while preserving their corner point. Not available in version 1.0 and above.
- Connect edges: Connect Sketcher elements by applying coincident constraints to endpoints. Not available in version 0.21 and above.
- Copy: Copies a Sketcher element. Not available in version 1.0 and above.
- Move: Moves the selected geometry taking as reference the last selected point. Not available in version 1.0 and above.
- Rectangular array: Creates an array of selected Sketcher elements. Not available in version 1.0 and above.
Preferences
- Preferences: Preferences for the Sketcher Workbench.
Best practices
Every CAD user develops their own way of working over time, but there are some useful general principles to follow.
- A series of simple sketches is easier to manage than a single complex one. For example, a first sketch can be created for the base 3D feature (either a pad or a revolve), while a second one can contain holes or cutouts (pockets). Some details can be left out, to be realized later on as 3D features. You can choose to avoid fillets in your sketch if there are too many, and add them as a 3D feature.
- Always create a closed profile, or your sketch won't produce a solid, but rather a set of open faces. If you don't want some of the objects to be included in the solid creation, turn them to construction elements with the Construction Mode tool.
- Use the Auto constraints feature to limit the number of constraints you'll have to add manually.
- As a general rule, apply geometric constraints first, then dimensional constraints, and lock your sketch last. But remember: rules are made to be broken. If you're having trouble manipulating your sketch, it may be useful to constrain a few objects first before completing your profile.
- If possible, center your sketch at the origin (0,0) with the Lock constraint. If your sketch is not symmetric, locate one of its points at the origin, or choose nice round numbers for the lock distances.
- If you have the possibility to choose between the Length constraint and the Horizontal or Vertical distance constraints, prefer the latter. Horizontal and Vertical distance constraints are computationally cheaper.
- In general, the best constraints to use are: Horizontal and Vertical constraints; Horizontal and Vertical length constraints; point-to-point Tangency. If possible, limit the use of these: the general Length constraint; edge-to-edge Tangency; Point on object constraint; Symmetric constraint.
- If in doubt about the validity of a sketch once it is complete (features turn green), close the Sketcher dialog and use Validate sketch.
Tutorials
- Sketcher Lecture by chrisb. This is a more than 80 page PDF document that serves as a detailed manual for the Sketcher. It explains the basics of Sketcher usage, and goes into a lot of detail about the creation of geometrical shapes, and each of the constraints.
- Basic Sketcher Tutorial for beginners
- Sketcher Micro Tutorial - Constraint Practices
- Sketcher requirement for a sketch Minimum requirement for a sketch and Complete determination of a sketch
Scripting
The Sketcher scripting page contains examples on how to create constraints from Python scripts.
Examples
For some ideas of what can be achieved with Sketcher tools, have a look at: Sketcher examples.
- General: Create sketch, Edit sketch, Attach sketch, Reorient sketch, Validate sketch, Merge sketches, Mirror sketch, Leave sketch, View sketch, View section, Toggle grid, Toggle snap, Configure rendering order, Stop operation
- Sketcher geometries: Point, Polyline, Line, Arc, Arc by 3 points, Arc of ellipse, Arc of hyperbola, Arc of parabola, Circle, Circle by 3 points, Ellipse, Ellipse by 3 points, Rectangle, Centered rectangle, Rounded rectangle, Triangle, Square, Pentagon, Hexagon, Heptagon, Octagon, Regular polygon, Slot, Arc slot, B-spline by control points, Periodic B-spline by control points, B-spline by knots, Periodic B-spline by knots, Toggle construction geometry
- Sketcher constraints:
- Dimensional constraints: Dimension, Horizontal distance, Vertical distance, Distance, Auto radius/diameter, Radius, Diameter, Angle, Lock
- Geometric constraints: Coincident (unified), Coincident, Point on object, Horizontal/vertical, Horizontal, Vertical, Parallel, Perpendicular, Tangent or collinear, Equal, Symmetric, Block
- Other constraints: Refraction (Snell's law)
- Constraint tools: Toggle driving/reference constraint, Activate/deactivate constraint
- Sketcher tools: Fillet, Chamfer, Trim, Split, Extend, External geometry, Carbon copy, Select origin, Select horizontal axis, Select vertical axis, Array transform, Polar transform, Scale transform, Offset geometry, Symmetry, Remove axes alignment, Delete all geometry, Delete all constraints
- Sketcher B-spline tools: Convert geometry to B-spline, Increase B-spline degree, Decrease B-spline degree, Increase knot multiplicity, Decrease knot multiplicity, Insert knot, Join curves
- Sketcher visual: Select unconstrained DoF, Select associated constraints, Select associated geometry, Select redundant constraints, Select conflicting constraints, Show/hide circular helper for arcs, Show/hide B-spline degree, Show/hide B-spline control polygon, Show/hide B-spline curvature comb, Show/hide B-spline knot multiplicity, Show/hide B-spline control point weight, Show/hide internal geometry, Switch virtual space
- Additional: Sketcher Dialog, Preferences, Sketcher scripting
- Getting started
- Installation: Download, Windows, Linux, Mac, Additional components, Docker, AppImage, Ubuntu Snap
- Basics: About FreeCAD, Interface, Mouse navigation, Selection methods, Object name, Preferences, Workbenches, Document structure, Properties, Help FreeCAD, Donate
- Help: Tutorials, Video tutorials
- Workbenches: Std Base, Assembly, BIM, CAM, Draft, FEM, Inspection, Material, Mesh, OpenSCAD, Part, PartDesign, Points, Reverse Engineering, Robot, Sketcher, Spreadsheet, Surface, TechDraw, Test Framework
- Hubs: User hub, Power users hub, Developer hub