Sketcher Workbench/pt

Introduction
The FreeCAD Sketcher Workbench is used to create 2D geometries intended for use in the  PartDesign Workbench,  Arch Workbench, and other workbenches. Generally, a 2D drawing is considered the starting point for most CAD models, as a 2D sketch can be "extruded" to create a 3D shape; further 2D sketches can be used to create other features like pockets, ridges, or extrusions on top of the previously built 3D shapes. Together with boolean operations defined in the Part Workbench, the Sketcher forms the basis of the constructive solid geometry (CSG) method of building solids. Moreover, together with the PartDesign Workbench operations, the Sketcher also forms the basis of the feature editing methodology of creating solids.

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.



Basics of constraint sketching
To explain how the Sketcher works, it may be useful to compare it to the "traditional" way of drafting.

Traditional Drafting
The traditional way of CAD drafting inherits from the old drawing board. Orthogonal (2D) views are drawn manually and intended for producing technical drawings (also known as blueprints). Objects are drawn precisely to the intended size or dimension. If you want to draw an horizontal line 100mm in length starting at (0,0), you activate the line tool, either click on the screen or input the (0,0) coordinates for the first point, then make a second click or input the second point coordinates at (100,0). Or you will draw your line without regard to its position, and move it afterwards. When you've finished drawing your geometries, you add dimensions to them.

Constraint Sketching
The Sketcher moves away from this logic. Objects do not need to be drawn exactly as you intend to, because they will be defined later on by constraints. Objects can be drawn loosely, and as long as they are unconstrained, can be modified. They are in effect "floating" and can be moved, stretched, rotated, scaled, and so on. This gives great flexibility in the design process.

What are constraints?
Instead of dimensions, 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.

Multiple objects can be constrained between 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 will have a number of different solutions, and making it fully-constrained means 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.

What the Sketcher is not good for
The Sketcher is not intended for producing 2D blueprints. Once sketches are used to generate a solid feature, they are automatically hidden. 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. Unlike Sketcher elements, Draft objects don't use constraints; they are simple shapes defined at the moment of creation. Both Draft and Sketcher can be used for 2D geometry drawing, and 3D solid creation, although their preferred use is different:
 * The Sketcher Workbench is normally used together with the Part and PartDesign workbenches to create solids.
 * The Draft Workbench is normally used for simple planar drawings over a grid, as when drawing an architectural floor plan. In these situations Draft is mostly used together with the Arch Workbench.

The tool Draft2Sketch converts a Draft object to a Sketch object, and vice versa. Many tools that require a 2D element as input work with either type of object as an internal conversion is done automatically.

Sketching Workflow
A Sketch is always 2-dimensional (2D). To create a solid, a 2D Sketch of a single enclosed area is created and then either Padded or Revolved to add the 3rd dimension, creating a 3D solid from the 2D Sketch.

If a Sketch has segments that cross one another, places where a Point is not directly on a segment, or places where there are gaps between endpoints of adjacent segments, Pad or Revolve won't create a solid. Sometimes a Sketch which contains lines which cross one another will work for a simple operation such as Pad, but later operations such as Linear Pattern will fail. It is best to avoid crossing lines. The exception to this rule is that it doesn't apply to Construction (blue) Geometry.

Inside the enclosed area we can have smaller non-overlapping areas. These will become voids when the 3D solid is created.

Once a Sketch is fully constrained, the Sketch features will turn green; Construction Geometry will remain blue. It is usually "finished" at this point and suitable for use in creating a 3D solid. However, once the Sketch dialog is closed it may be worthwhile going to Part Workbench and running  to ensure there are no features in the Sketch which may cause later problems.

Tools
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.

Sketcher toolbar

 * [[Image:Sketcher_NewSketch.svg‎‎|32px]] Create sketch: Creates‎ a new sketch on a selected face or plane. If no face is selected while this tool is executed the user is prompted to select a plane from a pop-up window.


 * [[Image:Sketcher_EditSketch.svg|32px]] Edit sketch: Edit the selected Sketch. This will open the Sketcher Dialog.


 * [[Image:Sketcher_MapSketch.svg|32px]] Map sketch to face: Maps a sketch to the previously selected face of a solid.


 * Sketcher_ReorientSketch.svg Reorient sketch: Allows you to attach the sketch to one of the main planes.


 * Sketcher_ValidateSketch.svg Validate sketch: Verify the tolerance of different points and adjust them.


 * [[Image:Sketcher_MergeSketches.svg|32px]] Merge sketches: Merge two or more sketches.


 * [[Image:Sketcher_MirrorSketch.svg|32px]] Mirror sketch: Mirror a sketch along the x-axis, the y-axis or the origin.

Sketcher Edit Mode toolbar

 * [[Image:Sketcher_LeaveSketch.svg|32px]] Leave sketch: Leave the Sketch editing mode.


 * [[Image:Sketcher_ViewSketch.svg|32px]] View sketch: Sets the model view perpendicular to the sketch plane.


 * [[Image:Sketcher_ViewSection.svg|32px]] View section: Creates a section plane that temporarily hides any matter in front of the sketch plane.

Sketcher edit tools toolbar

 * [[Image:Sketcher_Grid.svg|32px]] Toggle grid: Toggles the grid in the sketch currently being edited. Settings can be changed in the related menu.


 * [[Image:Sketcher_Snap.svg|32px]] Toggle snap: Toggles snapping in all sketches. Settings can be changed in the related menu.


 * [[Image:Sketcher_RenderingOrder.svg|32px]] Configure rendering order: The rendering order of all sketches can be changed in the related menu.

Other

 * Sketcher_StopOperation.svg Stop operation: When in edit mode, stop the current operation, whether that is drawing, setting constraints, etc.

Sketcher geometries
These are tools for creating objects.


 * [[Image:Sketcher_CreatePoint.svg|32px]] Point: Draws a point.


 * [[Image:Sketcher_CreateLine.svg|32px]] Line: Draws a line segment between 2 points. Lines are infinite regarding certain constraints.


 * [[Image:Sketcher_CompCreateArc.png|48px]] Create an arc: This is an icon menu in the Sketcher toolbar that holds the following commands:


 * [[Image:Sketcher_CreateArc.svg|32px]] Arc: Draws an arc segment from center, radius, start angle and end angle.


 * [[Image:Sketcher_Create3PointArc.svg|32px]] Arc by 3 points: Draws an arc segment from two endpoints and another point on the circumference.


 * [[Image:Sketcher_CompCreateCircle.png|48px]] Create a circle: This is an icon menu in the Sketcher toolbar that holds the following commands:


 * [[Image:Sketcher_CreateCircle.svg|32px]] Circle: Draws a circle from center and radius.


 * [[Image:Sketcher_Create3PointCircle.svg|32px]] Circle by 3 points: Draws a circle from three points on the circumference.


 * [[Image:Sketcher_CompCreateConic.png|48px]] Create a conic: The sketcher provides the following conical sections. Unlike B-splines they can be used with all sorts of constraints such as Tangent, Point On Object, or Perpendicular.


 * [[Image:Sketcher_CreateEllipseByCenter.svg|32px]] Ellipse by center: Draws an ellipse by center point, major radius point and minor radius point.


 * [[Image:Sketcher_CreateEllipseBy3Points.svg|32px]] Ellipse by 3 points: Draws an ellipse by major diameter (2 points) and minor radius point.


 * [[Image:Sketcher_CreateArcOfEllipse.svg|32px]] Arc of ellipse: Draws an arc of ellipse by center point, major radius point, starting point and ending point.


 * [[Image:Sketcher_CreateArcOfHyperbola.svg|32px]] Arc of hyperbola: Draws an arc of hyperbola.


 * [[Image:Sketcher_CreateArcOfParabola.svg|32px]] Arc of parabola: Draws an arc of parabola.


 * [[Image:Sketcher_CompCreateBSpline.png|48px]] Create a B-spline: This is an icon menu in the Sketcher toolbar that holds the following commands:


 * Sketcher_CreateBSpline.svg B-spline by control points: Draws a B-spline curve by its control points.


 * Sketcher_CreatePeriodicBSpline.svg Periodic B-spline by control points: Draws a periodic (closed) B-spline curve by its control points.


 * Sketcher_CreateBSplineByInterpolation.svg B-spline by knots:


 * Sketcher_CreatePeriodicBSplineByInterpolation.svg Periodic B-spline by knots:


 * [[Image:Sketcher_CreatePolyline.svg|32px]] Polyline (multiple-point line): Draws a line made of multiple line segments. Pressing the key while drawing a Polyline toggles between the different polyline modes.


 * [[Image:Sketcher_CompCreateRectangles.png|48px]] Create a rectangle: This is an icon menu in the Sketcher toolbar that holds the following commands:


 * [[Image:Sketcher_CreateRectangle.svg|32px]] Rectangle: Draws a rectangle from 2 opposite points.


 * [[Image:Sketcher_CreateRectangle_Center.svg|32px]] Centered rectangle: Draws a rectangle from a central point and an edge point.


 * [[Image:Sketcher_CreateOblong.svg|32px]] Rounded rectangle: Draws a rounded rectangle from 2 opposite points.


 * [[Image:Sketcher_CompCreateRegularPolygon.png|48px]] Create a regular polygon: This is an icon menu in the Sketcher toolbar that holds the following commands:


 * [[Image:Sketcher_CreateTriangle.svg|32px]] Triangle: Draws a regular triangle inscribed in a construction geometry circle.


 * [[Image:Sketcher_CreateSquare.svg|32px]] Square: Draws a regular square inscribed in a construction geometry circle.


 * [[Image:Sketcher_CreatePentagon.svg|32px]] Pentagon: Draws a regular pentagon inscribed in a construction geometry circle.


 * [[Image:Sketcher_CreateHexagon.svg|32px]] Hexagon: Draws a regular hexagon inscribed in a construction geometry circle.


 * [[Image:Sketcher_CreateHeptagon.svg|32px]] Heptagon: Draws a regular heptagon inscribed in a construction geometry circle.


 * [[Image:Sketcher_CreateOctagon.svg|32px]] Octagon: Draws a regular octagon inscribed in a construction geometry circle.


 * [[Image:Sketcher_CreateRegularPolygon.svg|32px]] Regular polygon : Draws a regular polygon by selecting the number of sides and picking two points: the center and one corner.


 * [[Image:Sketcher_CreateSlot.svg|32px]] Slot: Draws an oval by selecting the center of one semicircle and an endpoint of the other semicircle.


 * [[Image:Sketcher_CompCreateFillets.png|48px]] Create a fillet: This is an icon menu in the Sketcher toolbar that holds the following commands:


 * [[Image:Sketcher_CreateFillet.svg|32px]] Fillet: Creates a fillet between two non-parallel lines.


 * [[Image:Sketcher_CreatePointFillet.svg|32px]] Corner-preserving fillet: Creates a fillet between two non-parallel lines while preserving their (virtual) intersection.


 * [[Image:Sketcher_Trimming.svg|32px]] Trim: Trims a line, circle or arc with respect to the clicked point.


 * Sketcher_Extend.svg Extend: Extends a line or an arc to a boundary line, arc, ellipse, arc of ellipse or a point in space.


 * [[Image:Sketcher_Split.svg|32px]] Split: Splits an edge into two while keeping most of the constraints.


 * [[Image:Sketcher_External.svg|32px]] External geometry: Creates an edge linked to external geometry.


 * Sketcher_CarbonCopy.svg Carbon copy: Copies the geometry of another sketch.


 * Sketcher_ToggleConstruction.svg Toggle construction geometry: Toggles sketch geometry from/to construction mode. Construction geometry is shown in blue and is discarded outside of Sketch editing mode.

Sketcher constraints
Constraints are used to define lengths, set rules between sketch elements, and to lock the sketch along the vertical and horizontal axes. Some constraints require use of Helper constraints.

Geometric constraints
These constraints are not associated with numeric data.


 * Sketcher_ConstrainCoincident.svg Coincident: Affixes a point onto (coincident with) one or more other points. It acts as a concentric constraint if two or more circles, arcs, ellipses or arcs of ellipses are selected.


 * Sketcher_ConstrainPointOnObject.svg Point on object: Affixes a point onto another object such as a line, arc, or axis.


 * Sketcher_ConstrainVertical.svg Vertical: Constrains the selected lines or polyline elements to a true vertical orientation. More than one object can be selected before applying this constraint.


 * Sketcher_ConstrainHorizontal.svg Horizontal: Constrains the selected lines or polyline elements to a true horizontal orientation. More than one object can be selected before applying this constraint.


 * Sketcher_ConstrainParallel.svg Parallel: Constrains two or more lines parallel to one another.


 * Sketcher_ConstrainPerpendicular.svg Perpendicular: Constrains two lines perpendicular to one another, or constrains a line perpendicular to an arc endpoint.


 * Sketcher_ConstrainTangent.svg Tangent: Creates a tangent constraint between two selected entities, or a co-linear constraint between two line segments. A line segment does not have to lie directly on an arc or circle to be constrained tangent to that arc or circle.


 * Sketcher_ConstrainEqual.svg Equal: Constrains two selected entities equal to one another. If used on circles or arcs their radii will be set equal.


 * Sketcher_ConstrainSymmetric.svg Symmetric: Constrains two points symmetrically about a line, or constrains the first two selected points symmetrically about a third selected point.


 * [[Image:Sketcher_ConstrainBlock.svg|32px]] Block: it blocks an edge from moving, that is, it prevents its vertices from changing their current positions. It should be particularly useful to fix the position of B-Splines. See the Block Constraint forum topic.

Dimensional constraints
These are constraints associated with numeric data, for which you can use the expressions. The data may be taken from a spreadsheet.


 * Sketcher_ConstrainLock.svg Lock: Constrains the selected item by setting vertical and horizontal distances relative to the origin, thereby locking the location of that item. These constraint distances can be edited later.


 * Sketcher_ConstrainDistanceX.svg Horizontal distance: Fixes the horizontal distance between two points or line endpoints. If only one item is selected, the distance is set to the origin.


 * Sketcher_ConstrainDistanceY.svg Vertical distance: Fixes the vertical distance between 2 points or line endpoints. If only one item is selected, the distance is set to the origin.


 * Sketcher_ConstrainDistance.svg Distance: Defines the length of a line, the perpendicular distance between a point and a line, the distance between two points, or,, the distance between the edges of two circles.


 * [[Image:Sketcher_CompConstrainRadDia.png|48px]] Constrain radius or diameter: This is an icon menu in the Sketcher constraints toolbar that holds the following commands:


 * Sketcher_ConstrainRadius.svg Radius or weight: Defines the radius of an arc or circle or the weight of a B-spline pole.


 * Sketcher_ConstrainDiameter.svg Diameter: Defines the diameter of an arc or circle.


 * Sketcher_ConstrainRadiam.svg Auto radius/diameter: Defines the radius of an arc, the diameter of a circle or the weight of a B-spline pole.


 * Sketcher_ConstrainAngle.svg Angle: Defines the internal angle between two selected lines.

Special constraints

 * Sketcher_ConstrainSnellsLaw.svg Refraction (Snell's law): Constrains two lines to obey a refraction law to simulate the light going through an interface.

Constraint tools
The following tools can be used the change the effect of constraints:


 * Sketcher_ToggleDrivingConstraint.svg Toggle driving/reference constraint: Toggles the toolbar or the selected constraints to/from reference mode.


 * Sketcher_ToggleActiveConstraint.svg Activate/deactivate constraint: Enable or disable an already placed constraint.

Sketcher tools

 * Sketcher_SelectElementsWithDoFs.svg Select unconstrained DoF: Highlights in green the geometry with degrees of freedom (DOFs), i.e. not fully constrained.


 * Sketcher_SelectConstraints.svg Select associated constraints: Selects the constraints of a sketcher element.


 * Sketcher_SelectElementsAssociatedWithConstraints.svg Select associated geometry: Select sketcher elements associated with constraints.


 * Sketcher_SelectRedundantConstraints.svg Select redundant constraints: Selects redundant constraints of a sketch.


 * Sketcher_SelectConflictingConstraints.svg Select conflicting constraints: Selects conflicting constraints of a sketch.


 * Sketcher_RestoreInternalAlignmentGeometry.svg Show/hide internal geometry: Recreates missing/deletes unneeded internal geometry of a selected ellipse, arc of ellipse/hyperbola/parabola or B-spline.


 * Sketcher_SelectOrigin.svg Select origin: Selects the origin of a sketch.


 * Sketcher_SelectHorizontalAxis.svg Select horizontal axis: Selects the horizontal axis of a sketch.


 * Sketcher_SelectVerticalAxis.svg Select vertical axis: Selects the vertical axis of a sketch.


 * Sketcher_Symmetry.svg Symmetry: Copies a sketcher element symmetrical to a chosen line.


 * Sketcher_Clone.svg Clone: Clones a sketcher element.


 * Sketcher_Copy.svg Copy: Copies a sketcher element.


 * Sketcher_Move.svg Move: Moves the selected geometry taking as reference the last selected point.


 * Sketcher_RectangularArray.svg Rectangular array: Creates an array of selected sketcher elements.


 * Sketcher_RemoveAxesAlignment.svg Remove axes alignment: Remove axes alignment while trying to preserve the constraint relationship of the selection.


 * Sketcher_DeleteAllGeometry.svg Delete all geometry: Deletes all geometry from the sketch.


 * Sketcher_DeleteAllConstraints.svg Delete all constraints: Deletes all constraints from the sketch.

Sketcher B-spline tools

 * Sketcher_BSplineDegree.svg Show/hide B-spline degree


 * Sketcher_BSplinePolygon.svg Show/hide B-spline control polygon


 * Sketcher_BSplineComb.svg Show/hide B-spline curvature comb


 * Sketcher_BSplineKnotMultiplicity.svg Show/hide B-spline knot multiplicity


 * Sketcher_BSplinePoleWeight.svg Show/hide B-spline control point weight


 * Sketcher_BSplineApproximate.svg Convert geometry to B-spline


 * Sketcher_BSplineIncreaseDegree.svg Increase B-spline degree


 * Sketcher_BSplineDecreaseDegree.svg Decrease B-spline degree


 * Sketcher_BSplineIncreaseKnotMultiplicity.svg Increase knot multiplicity


 * Sketcher_BSplineDecreaseKnotMultiplicity.svg Decrease knot multiplicity


 * Sketcher_BSplineInsertKnot.svg Insert knot,


 * Sketcher_JoinCurves.svg Join curves,

Sketcher virtual space

 * Sketcher_SwitchVirtualSpace.svg Switch virtual space: Allows you to hide all constraints of a sketch and make them visible again.

Obsolete tools

 * Sketcher_CloseShape.svg Close shape: Creates a closed shape by applying coincident constraints to endpoints. Not available in.


 * Sketcher_ConnectLines.svg Connect edges: Connect sketcher elements by applying coincident constraints to endpoints. Not available in.

Preferences

 * [[Image:Workbench_Sketcher.svg|32px]] Preferences: Preferences for the Sketcher workbench.

Best Practices
Every CAD user develops his 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 to the origin (0,0) with the lock constraint. If your sketch is not symmetric, locate one of its points to 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; Fix Point Onto a Line Constraint; Symmetry Constraint.
 * If in doubt about the validity of a sketch once it is complete (features turn green), close the Sketcher dialog, switch to the [[Image:Workbench_Part.svg|24px]] Part Workbench and run.

Tutorials

 * Sketcher tutorial by chrisb. This is a 70-page long 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.