Basic Part Design Tutorial 019

Introduction
This is an updated version of the Basic Part Design Tutorial.



This tutorial introduces users to the PartDesign Workbench. In this tutorial we will create a 3D solid model of the part shown in the image above. In the Drawing at the end of this paragraph all the necessary dimensions to complete the task are given.

We will start by creating a core solid shape from a base Sketch and then build on that shape, adding what are known as Features. These features will either add material to, or remove material from the solid by use of additional sketches and accompanying feature operations.

We will follow some of the techniques described in Advice for creating stable models:
 * A master sketch is used.
 * Named constraints are used to hold dimensions that can be readily referenced later in the model construction. For instance, to change the model width from 53 mm, as in the technical drawing, to 55 mm we need only to modify the Length value of the appropriate named constraint in the master sketch and the whole model will modify accordingly. This is parametric design in action.
 * External Geometries are potentially subject to the Topological Naming Problem. We will be using them only when strictly necessary and will attempt to refer to the most stable elements available. Referring to edges or vertices of prior sketches is normally more stable than referencing edges or vertices of generated solid geometry.

This Tutorial will not use every feature and tool available in the Part Design Workbench, but will provide a basic foundation upon which users can build their knowledge and skills.

Feel free to signal any errors or problems in this forum thread: New Part Design Tutorial for FC 019 and 020.



Preliminary notes

 * This tutorial will provide detailed descriptions when it describes an operation for the first time; subsequent operations will have a more concise description. When in doubt, find the operation that contains the more detailed description. For instance, when creating a sketch for the first time the process of choosing the sketch Plane will be explained in detail, for subsequent sketches it will not.
 * See |https://wiki.freecadweb.org/Part_and_PartDesignPartDesign Workbench Concepts for some conceptual background.
 * See the Sketcher WorkBench for a more detailed explanation of some of the terminology used here.
 * This tutorial assumes that in the Sketcher's Edit controls window is checked. This ensures that some constraints are applied automatically. If this is not the case you will need to apply them yourself.
 * You exit a Sketcher drawing tool by pressing the key or by right-clicking an empty area of the 3D view. The mouse cursor should change to the standard arrow cursor. If you press  an additional time you will exit the sketch edit mode. To return to the editor, click on the Model tab, then either double-click the Sketch element in the tree, or right-click it and select Edit sketch from the context menu.
 * If Sketcher's Solver detects a redundant constraint it will turn the sketch orange in color. Before further constraints are added, redundant constraints should be removed. (Redundant constraints are shown in the task panel - click on the blue reference and press .)
 * It's possible that some elements of the side panel, for instance the button may not be visible if the side panel is not wide enough. You can make it wider by dragging its right border. Place your mouse pointer over the border; when the pointer changes to a two-way arrow, press and hold the left mouse button and drag.

Startup
First begin by making sure you are in PartDesign Workbench, selected from the drop-down menu. Once there, you will want to create a new document if you have not done so already. It is a good habit to save your work often, so first save the new document, giving it any name you choose.

All work in Part Design begins with a Body. Then we will build the solid inside the body by starting with a sketch.

Click on Create new body to create and activate a new Body Container. ''Note: this step can be omitted. When creating a sketch using Part Design|Sketch|Create Sketch, if no existing Body is found, a new one is automatically created and activated. This is not the case if you create a sketch using the Sketcher workbench, as sketches are useful in workbenches other than Part Design.''

Master sketch
You will create the the master sketch containing the model's rectangular base shape and two named constraints that will be created to supply correct dimensions to other parts of the model:
 * length that will contain 53mm (the result of adding the 39mm dimension to the two 7mm sides).
 * width that will contain 26mm.

 Sketch 



Step 1: Create the sketch


 * 1) Click on [[Image:PartDesign_NewSketch.svg|24px|link=PartDesign_NewSketch]] Create new sketch. This will create the sketch within the just created body. It will be named Sketch.
 * 2) A task panel like Fig: MS1 will open where you have to choose to which plane the sketch will be attached.
 * 3) Select XY_Plane from the list.
 * 4) Press.
 * 5) FreeCAD automatically switches to the Sketcher Workbench.
 * 6) The sketch is opened in edit mode: you will see something like Fig: MS2.

Step 2: Add geometry


 * 1) Click on Sketcher_CreateRectangle.svg Rectangle tool.
 * 2) Click two points to create a rectangle roughly centered around the Y axis similar to Fig: MS3. Note:
 * 3) * Don't place points on X axis as the Solver will automatically apply constraints that will create a problem later.
 * 4) * The dimensions of the rectangle are unimportant at this point. They will be assigned using constraints in a later step.
 * 5) Once done, press, or right-click, to exit "rectangle creation mode". "Rectangle creation mode" is indicated by this cursor appearance: [[File:Pd tut rec cursor.png]].

Step 3: Assign a horizontal constraint


 * Assign now a horizontal distance constraint this way:


 * 1) Select the line defined by P2 and P3 in Fig: MS3.
 * 2) Use the button Sketcher_ConstrainDistanceX.svg horizontal distance constraint:
 * 3) A dimension will appear between extreme points of the line selected. This dimension is the current distance.
 * 4) Additionally, a dialog will appear: Pd tut rect03.png
 * 5) Set Length = 53mm, and to be able to easily reference this dimension later a name is required. You are free to use the name of your choice. It need only be unique within the sketch. Assign Name = length.
 * 6) Click.
 * 7) The result should resemble Fig: MS4

Step 4: Assign a symmetrical constraint


 * To center the the top edge of the rectangle around the origin proceed as follows:


 * 1) Select points P2 and P3 of the rectangle.
 * 2) Select the origin of the sketch. ''Note: the selection order of the points is important.
 * 3) Use Sketcher_ConstrainSymmetric.svg Symmetric tool.
 * 4) You will end up with something that resembles Fig: MS5.
 * 5) Making a good choice of origin of the model can simplify its construction, in this case by taking advantage of the part's reflection symmetry in a later steps.

Step 5: Assign a vertical constraint


 * You now assign a vertical distance constraint, using a procedure analogous to the prior horizontal distance constraint


 * 1) Select the line defined by P3 and P4 in Fig: MS3.
 * 2) Click on Sketcher_ConstrainDistanceY.svg vertical distance constraint:
 * 3) Assign Length = 26 mm
 * 4) Assign Name = width.
 * 5) Click.
 * 6) Result should resemble Fig: MS6.
 * 7) Note the following:
 * 8) * The lines on the sketch will become "bright green". (Assuming you have not modified the default color theme).
 * 9) * The Solver messages window displays Fully constrained.
 * 10) * If you select any line or vertex of the sketch and try to drag it, it won't move.

Step 6: Close the sketch


 * Click the button at the top of the tasks panel to leave sketch edit mode.

Main profile
You will create a new sketch that is holding the main profile.

 Sketch001 



Step 1: Create the sketch


 * Click on [[Image:PartDesign_NewSketch.svg|24px|link=PartDesign_NewSketch]] Create new sketch. Create it in YZ_Plane. FreeCAD will assign the name of Sketch001.

Step 2: Add geometry


 * 1) Use the [[Image:Sketcher_CreatePolyline.svg|24px|link=Sketcher_CreatePolyline]] Polyline tool to make a shape like that in Fig: MP1.
 * 2) The labels P1, P2 etc. will not appear in the Sketcher. They were added as references.
 * 3) The three vertical and horizontal constraints you see in the image are added automatically by the auto-constraints provided you drew the lines that way. If you didn't you need to add them.
 * 4) When you close the figure, make sure the first point is selected when you click to create the final line. The selected point will change color and you will see the symbol for a Sketcher_ConstrainCoincident.svg Coincident constraint appear by the vertex. Coincidence constraints have to be explicit - just having two vertices visually coincident is not sufficient.
 * 5) As done in first sketch you will assign additional constraints later to adjust the dimensions and exact shape (see note about Constraints below).

Step 3: Assign constraints


 * 1) Select the point P2 and the Y-axis and apply a Sketcher_ConstrainPointOnObject.svg Point on object constraint.
 * 2) Select the origin and the point P1 and apply a Sketcher_ConstrainHorizontal.svg Horizontal constraint. Why not a Sketcher_ConstrainCoincident.svg Coincident constraint, you might ask. Try it (and undo). The sketch will turn orange and a solver message redundant constraints will appear. Because the line P1-P2 has already been constrained to be vertical, the only remaining degree of freedom is P1's y-coordinate. The coincidence constraint sets both the x- and y-coordinates to zero, but the x-coordinate is already determined. The horizontal constraint, on the other hand, only sets the y-coordinate to zero, which is sufficient.
 * 3) Select the line defined by points P2 and P3 and apply a Sketcher_ConstrainDistanceX.svg horizontal distance constraint and assign Length = 5 mm.
 * 4) Select the line defined by points P1 and P2 and apply a Sketcher_ConstrainDistanceY.svg vertical distance constraint and assign Length = 26 mm.
 * 5) Select the line defined by points P4 and P1 and apply a Sketcher_ConstrainDistanceX.svg horizontal distance constraint:
 * 6) For this value you will use a "Named constraint" using Expressions. To do so you have to press the little button on the dimensions [[Image:Bound-expression.svg|24px]], and you will be presented with a new dialog window named Formula editor that contains an input field and a Result: label, similar to the image below: Pd tut expressions.png When you start typing in the input field, you will be presented with some autocompletions.
 * 7) Select the label of the sketch. In our case we want  . Note the period after the "element label".
 * 8) To select named constraint "width", you have to enter   with the period. Here autocomplete works.
 * 9) To add "width", as yet autocompletion is not available, so complete the cell to read  . If all went well the "red error message" in the Result: field has been replaced by the correct value as in the figure below: Pd tut expression end.png
 * 10) Click  to close Formula editor dialog.
 * 11) Click  to close Insert length dialog.
 * 12) At this point you should have a fully constrained sketch similar to Fig: MP2.
 * 13) Note the subtly different colors used for distance constraints assigned using expressions and those assigned specifying a length.

Step 4: Close the sketch


 * Click the button at the top of the tasks panel to leave sketch edit mode.

 Pad 




 * 1) Make sure Sketch001 is selected.
 * 2) Click PartDesign_Pad.svg Pad:
 * 3) The Pad task panel opens.
 * 4) For Type select.
 * 5) For Length you will use again an Expression but this time you will enter   in the field. This should evaluate to 53 mm.
 * 6) Select.
 * 7) Click  to close the task panel.
 * 8) Once that is done you will have a solid as shown in Fig: MP3.

Corner cutouts
 Sketch002 



Step 1: Hide the solid


 * Hide the just created solid: Select Pad and click the.

Step 2: Create the sketch


 * Click on [[Image:PartDesign_NewSketch.svg|24px|link=PartDesign_NewSketch]] Create new sketch in XZ_Plane. Sketch will be named Sketch002.

Step 3: Add geometry


 * Select Sketcher_CreateRectangle.svg Rectangle tool, and create a rectangle. Do not create it too near an axis, to avoid any automatic constraints that would make it difficult to move into the correct position using the External geometry tool.

Step 4: Assign dimensional constraints


 * 1) Select one of the horizontal lines apply a horizontal distance constraint and a value of 11 mm.
 * 2) Select one of the vertical lines and give it a vertical distance constraint and a value of 5 mm.
 * 3) You should obtain something similar to Fig: CC1.

Step 5: Close the sketch


 * Click at the top of the task panel. Sketch002 will not be not fully constrained at this stage.

Step 6: Make previous sketches visible


 * To use External geometry the sketches whose elements we want to reference must be visible. Make sure Sketch and Sketch001 are both visible. Use the to toggle visibility if needed.

Step 7: Applying External geometries constraints
 * 1) Double click on Sketch002 to activate edit mode. Rotate the view so you can clearly see the points as shown in Fig: CC2. This will ease subsequent steps. Note that the rectangle's initial position could be different in your sketch.
 * 2) Select Sketcher_External.svg External geometry tool, the cursor will became [[File:Pd tut eg cursor.png]].
 * 3) Select with this cursor point P1 in Fig: CC3, selected point will remain highlighted and in the Elements tab of task panel you will see that this element is shown [[File:Pd tut ext geom pt.png]].
 * 4) Select with this cursor point P2 in Fig: CC3. In the Elements tab of task panel you will see another element like the above.
 * 5) Right-click or press  to terminate External Geometry selection. The cursor will return to the standard arrow pointer.
 * 6) Select point P1 and point P3 and apply a Sketcher_ConstrainVertical.svg Vertical Constraint. The rectangle will be aligned with the X position of selected point.
 * 7) Select point P2 and point P3 and apply a Sketcher_ConstrainHorizontal.svg Horizontal Constraint. The rectangle will be aligned with the Y position of the selected point.
 * 8) Sketch002 should now show green as "fully constrained".

Step 8: Close the sketch


 * Click at the top of the task panel.

 Pocket 



To create the cutouts we will use the Pocket tool. This tool is the opposite of the Pad tool. Whereas the Pad tool adds material to the part, the Pocket tool removes material from the part.


 * 1) Select Pad and unhide it.
 * 2) Select Sketch002.
 * 3) Select PartDesign_Pocket.svg Pocket and configure the operation:
 * 4) Select Type.
 * 5) Check
 * 6) Click the  button.
 * 7) You should have something that resembles Fig: CC5

 Mirror 

Instead of creating another sketch and pocketing it, we can take advantage of the model's symmetry about the YZ plane and use Mirrored.


 * 1) Select Pocket.
 * 2) Click PartDesign_Mirrored.svg Mirrored:
 * 3) A task panel will open.
 * 4) Select Plane  from the pulldown menu. The plane will be defined by this axis (the Y axis) and also by the Z axis of the sketch. We could also have selected Base_YZ_Plane to obtaining the same result.
 * 5) Click.
 * 6) If all has gone well, you should now have a part that looks like Fig: CC6.

Sides
 Sketch003 




 * 1) Make sure Sketch is visible, and Mirrored is hidden.
 * 2) Click on [[Image:PartDesign_NewSketch.svg|24px|link=PartDesign_NewSketch]] Create new sketch and create the new sketch in XY_Plane; Sketch will be named Sketch003.
 * 3) Select Sketcher_CreateRectangle.svg Rectangle tool, and create a rectangle, similar to those in Fig: SD1. This should not trigger any auto constraint, because we offset our rectangle from the x-axis.
 * 4) Apply these constraints:
 * 5) Select one of the horizontal lines apply a horizontal distance constraint and a value of 7 mm.
 * 6) Select one of the vertical lines and give it a vertical distance constraint using an Expression and assigning the distance  .
 * 7) Add an Sketcher_External.svg External geometry using the point P1 as shown in Fig: CC3. (Vertices are somewhat finicky to select. Selecting any line containing P1 will create external references to both ends.)
 * 8) Select both the top-left point of created rectangle, (marked TL in in Fig: SD1) and the newly added External Geometry reference to P1.
 * 9) Apply a Sketcher_ConstrainCoincident.svg Coincident Constraint.
 * 10) The sketch should be fully constrained now.
 * 11) Click  at the top of the task panel.

 Pad001 


 * 1) Select Sketch003.
 * 2) Click PartDesign_Pad.svg Pad:
 * 3) Assign Type = .
 * 4) Assign Length = 16.70 mm
 * 5) Click.
 * 6) You should have a result as shown in Fig: SD2

 Mirrored001 


 * 1) Select Pad001.
 * 2) Click on PartDesign_Mirrored.svg Mirrored:
 * 3) Make sure Plane  from the pulldown menu, is selected.
 * 4) Click.
 * 5) If all has gone well, you should now have a part that looks like Fig: SD3.

 Note: 

Our two mirror operations have a common symmetry plane, so we could have made our model a little simpler by combining them. We would
 * 1) Omit the Mirror operation above
 * 2) Select both Pad001 and Pocket in step 1 of the above Mirrored001 operation.

This emphasizes the important concept that we are mirroring the selected features (the operations we performed on the body, in the order selected), not the body itself.

Center hole
Now it is time for the most challenging part of our modeling, a challenge that arises because the central pocket dimensions are referred to the slanted face.

If you use as a reference points on the slanted face created by padding Sketch001, you expose yourself to the Topological naming problem. A better solution is to reference Sketch001 itself when creating our next sketch as follows.

 Sketch004 




 * 1) Make Sketch visible, and Mirrored001 hidden.
 * 2) Click on [[Image:PartDesign_NewSketch.svg|24px|link=PartDesign_NewSketch]] Create new sketch, and create the new sketch in the YZ Plane. This will create a sketch named Sketch004.
 * 3) Using [[Image:Sketcher_CreatePolyline.svg|24px|link=Sketcher_CreatePolyline]] Polyline tool, trace a polyline like that indicated by the points P1, P2, P3, P4 in Fig: CH1.
 * 4) Remember to close the polyline by clicking the last point over the selected first point. This will create the required coincidence constraint.
 * 5) Check the applied constraints:
 * 6) * Delete the redundant Sketcher_ConstrainVertical.svg Constraint vertical applied to the line defined by P1 and P2.
 * 7) * Make sure there is a Sketcher_ConstrainHorizontal.svg Constraint horizontal on lines defined by P1 and P4, and P2 and P3.
 * 8) * Make sure there is a Sketcher_ConstrainPointOnObject.svg Point on object on P1 and P2 on the Y axis.
 * 9) Using Sketcher_External.svg External geometry tool select line defined by EGP1 and EGP2 on Sketch001 indicated in Fig: CH2  with purple color.
 * 10) Apply Sketcher_ConstrainPointOnObject.svg Point on object to P3 and P4, selecting the point and the external geometry, this will make line P3 to P4 coincident with line defined by EGP1 and EGP2 in Sketch001.
 * 11) Apply Sketcher_ConstrainDistance.svg Distance to line P3 to P4 and assign Length = 17.00mm
 * 12) Apply Sketcher_ConstrainDistance.svg Distance to P4 and EGP2 and assign Length = 7.00mm.
 * 13) This will result in a fully constrained sketch like in Fig: CH2.
 * 14) Click  at the top of the task panel.

 Pocket001 

Now you have to model central pocket, Drawing specify its distance from side pad as 11mm. An easy calculation shows that with this dimension the pocket is centered, having modeled the solid  symmetric around the Y axis is more easy to place the pocket.


 * 1) Select Sketch004.
 * 2) Select PartDesign_Pocket.svg Pocket and configure the operation:
 * 3) Select Type.
 * 4) Assign 8.50mm to Length and Length2 values
 * 5) Click the  button.
 * 6) Select the newly created Pocket001.
 * 7) Change its Refine property to True.

 Notes: 


 * 1) Refine will try to delete "seams" left by previous operations. It is advisable to only Refine the final solid obtained, as some operations can fail if Refine is activated. (However, there are also cases where Refine can make an operation succeed. So in case of problems check this property and test. Unfortunately there is not yet a general rule to follow.)
 * 2) Alternatively we could have used Type, checked Symmetric to Plane and entered 17 mm for the Length value''

Result
Your model is complete. It should look like the image below.

Single click on Sketch in the Tree View. Look for Sketch|Constraints in the Data tab and check on the effects of changing the length and/or width properties. The model should change parametrically.