In this tutorial we'll assemble 3 parts inside a single FreeCAD document, and animate the movement using a master sketch:
- the base is fixed and holds 2 axes
- the disk rotates around one of the axes
- the arm can wiggle around the base's other axis
- the disk has a nipple that is prisoner in a slot in the arm
- all 3 parts and the full assembly are in 1 single FreeCAD file
It is assumed that you have completed the 1st Assembly4 tutorial and that you have some experience with designing with FreeCAD, especially the PartDesign and Sketcher workbenches.
We start with an empty FreeCAD:
- Create a new document: File > New (or ctrl-n)
- In that document, create a new Assembly4 Model: Assembly > Create a new Model (or ctrl+m)
- Create also 3 new Parts: Assembly > Create a new Part, and call them
- base
- disk
- arm
- Note that these 3 parts are in the Parts group
- Save the document and call it asm_tuto2.fcstd
Result: The document is now ready to be used by Assembly4.
We will first create the functional structure of the assembly, and only then will we design the parts composing the assembly. The functional structure consists of sketches and datum objects at the root of the assembly, and placed at real functional locations, like rotation axes, planes, fixation points, translation axes ...
We present here a way of doing an assembly — a functional assembly as opposed to a geometrical assembly — that is based on the real mechanical functions of the assembly, and not on the geometrical features of the parts in the assembly. It is interesting to note that, in fine, all assemblies are functional assemblies, but when making a geometrical assembly you somehow reverse-engineer the functions of the geometrical features that the designer of the part has implemented to match the mechanical functions of the part. In other words, if, for example, there is a — geometrical — hole in a part to hold an axis, it's because the designer knew that there is going to be a — functional — rotation there, and not because of some lucky magic.
Such a functional assembly is also called top-down design, as opposed to bottom-up design where you assemble finished parts.
At first glance, this functional assembly, or top-down design, might seem less intuitive than the geometrical assembly that most CAD software propose, but once used to it it is more natural, and also much more robust: if, for example, you define a datum axis for a rotation, you don't need to know the mechanical details of how you will realize the rotation, and you can already assemble your parts around that datum axis. It is therefore possible to split and parallelize the detail design of each part between designers and still be sure that all the parts will come correctly together.
We will create variables that drive our assembly. First, create a variable that is the angle of rotation of the disk w.r.t. the base:
- Create a new variable: Assembly > Add variable
- Choose the Type : Float (this a decimal floating-point number)
- Name it: Angle_disk
- Set default value to 30.00
- Click OK
Create in the same way 2 other variables for the disk radius (R_disk with value 100.00) and the distance of the arm's pivot (Dist_pivot with value 300.00).
Result: We have created numercial variables in the App::FeaturePython object called Variables (see Model tree), that can be used in the ExpressionEngine of any parameter in this document with: Variables.Angle_disk , Variables.Dist_pivot and Variables.R_disk
We will now create the proper master sketch of our assembly:
- In the model tree, select the Model
- Create a new sketch: Assembly > New sketch
- Call it Sketch_master
- This will launch the attachment dialog of the sketch
- As first reference, select the LCS_0 in the model tree (or type LCS_0 by hand into the field)
- As Attachment mode select Object's XY
- Click OK
Result: We have created an empty sketch in the Assembly4 Model and attached it to the X-Y plane of our assembly. Now we'll draw the sketch:
- Right-click on Sketch_master and choose Edit sketch.
- Draw a first straight line from the origin.
- this line represents the rotation orientation of the disk
- Create an angle constraint between the line and the X-axis
- Clicking on the f(x) sign at the edge of the input field pops-up the ExpressionEngine editor
- Enter Variables.Angle_disk (watch out for the autocompletion)
- Click OK
Note: the dimension colour has changed from red to orange (depending on your settings)
Result: We have assigned the value of the variable Angle_disk to the angle between this line and the X-axis.
- In the same way, set the length of the line to R_disk
- the edge of the line represents the position of the nipple on the disk that slides in the slot of the arm
- Add another line between the edge of this line and the X-axis
- this line represents the orientation of the arm
- Set the distance between the edge of this second line and the Y-axis to Dist_pivot
Note: if a FreeCAD sketch is fully constrained then the lines change from white to green (depending on your settings).
- Close
Result: Our master sketch is finished.
Note: It is important to note that there are many ways to build a master sketch to represent a given assembly structure, so we suggest you take your time to build a well working master sketch before going into the detailed geometrical design of your parts. In our example, the kinematic is voluntarily very simple and thus the master sketch is also very simple. As a general rule, any problem that can be reduced to a 2D geometry can be easily modeled in this way. Some assemblies that are in 3D space can be modeled by a series of master sketches, but there are also some fully 3D setups that cannot, in any way, be modeled like this: a hexapod for example.
We will now create two LCS to attach the rotating disk and the pendling arm. The base will be fixed to the existing LCS_0 of the assembly. These coordinate systems (of type PartDesign::CoordinateSystem) are used in the Assembly4 way to attach links to parts into the assembly.
Note: the default coordinate systems of the 3 (empty) parts can be in the way of easy selection, therefore it can be useful to hide all the 3 parts temporarily. When hidden, an object's icon becomes grayed in the Model tree. As a general rule, don't hesitate to show and hide parts as necessary: sometimes it's better to have everything visible, sometimes it's better to see a single object.
- Select the Assembly4 Model and create a new Coordinate System : Assembly -> New Coordinate System)
- Call it LCS_disk
- this activates the attachment dialog
- As first reference select the origin vertex in Sketch_master
- As second reference select the first line in Sketch_master
- Choose Align O-X-Y as attachment mode
- Click OK
Result: LCS_disk is now oriented along the first line of Sketch_master
We do now the same thing with another coordinate system, call it LCS_arm and attach it to the line in the master sketch representing ... the arm.
As a final check before doing the part designs you can animate the master sketch and verify that the LCS move as they should (see next section of this tutorial). You can also change the values of the variables Dist_pivot and R_disk to check that everything works as expected. Save.
Result: we have now created 3 coordinate systems placed and oriented as the final 3 parts shall be placed:
- LCS_0 for the base part
- LCS_disk for the disk part
- LCS_arm for the arm part
Before going any further, we'll check that our sketch is working as expected by animating it:
- Click on the Animate Assembly button (or menu Assembly -> Animate Assembly)
- Select the variable Angle_disk
- Choose 40 and 400 as Begin and End values
- Choose 1 as Step and 0 for Sleep
- Click Run
Result: Check that the lines of the Sketch_master move as expected and that all LCS follow them. If not, something went wrong and you must fix it before going further.
We will now design the 3 parts that build our assembly. In order to avoid confusion, we recommend to hide all other parts than the one you are actively designing.
We'll do the geometrical design with the PartDesign workbench. It is assumed that you know how to design these parts using FreeCAD, we won't detail the method.
- Hide the parts disk and arm, and also hide the assembly Model
- Select the part base in the Model tree
- Create a new Body with the Assembly4 workbench (not through the PartDesign workbench ! Creating a Body with Assembly4 assures that the Body is placed inside the part that is selected.)
- Right-click on the newly created Body and Toggle Active Body
- this switches to the PartDesign workbench (that's OK now)
- Create the following geometry:
- set the distance between the 2 pivots to the variable Dist_pivot
Result: the part base is finished
- Select the part disk
- Create a new Body and activate it
- Create the following geometry:
- set nipple along the X axis at the distance R_disk from the origin
Result: the part disk is finished
-
Select the part arm
-
Create a new Body and activate it
-
Create the following geometry:
- set slot along the X axis with a length R_disk × 2
- set the distance of the pivot hole at the distance Dist_pivot from the origin
-
Switch to the Assembly4 workbench
-
Select the part arm
-
Create a new coordinate system, call it LCS_pivot
- this LCS_pivot must be at the root of the part arm and not in the Body
-
Attach LCS_pivot to the original LCS of the part arm (called LCS_1002 in our design, this might be different for your model) with the Object's X Y Z mode
- set the ExpressionEngine of the X value in the AttachmentOffset to Dist_pivot
-
Click OK
Result: the part arm is finished
Save document.
Now that we have created our master sketch and designed all our parts, we can assemble them. As usual in Assembly4, the assembly holds (App::Link) links to the (App::Part) parts, not the parts themselves, even though the parts are in the same document here. Thus, making assemblies with parts in the same document is identical as making assemblies with parts from external documents. Actually, it is possible to mix both methods at will.
The only difference is that, since a FreeCAD document can only contain one Assembly4 Model, only one level assemblies are possible if everything is in the same document. For large assemblies this is a severe limitation, therefore in order to make nested assemblies — assemblies of sub-assemblies and sub-sub-assemblies — it is mandatory to have several documents. See tutorial 1 for how to make assemblies from external parts.
- Hide all three parts base, disk and arm, and show the assembly Model
- Insert the part base
- Attach it's LCS_1 to the LCS_0 of the assembly
Note: Since all objects in a FreeCAD document need to have a unique name, the links to the parts we inserted cannot have the same name as the original parts, therefore FreeCAD automatically renamed the link to base as base_001. This is another limitation of single documents assemblies.
- Set the variable Angle_disk to 45 for better visualization
- Insert the part disk
- Attach it's LCS_1001 to the LCS_disk of the assembly
- Insert the part arm
- Attach it's LCS_pivot to the LCS_arm of the assembly
- you might need to add a rotation around Z Rot Z to correctly orientate the arm
Since we attached all parts to their respective coordinate systems, they are correctly placed and oriented, but if you look carefully they collide because we didn't care about their heights. This must be adjusted using the link's AttachmentOffset property:
- Select the instance arm001
- Set the z position of the AttachmentOffset property to 10
The final step: animate the assembly and check that all parts move as desired:
- Click on the Animate Assembly button (or menu Assembly -> Animate Assembly)
- Select the variable Angle_disk
- Choose 40 and 400 as Begin and End values
- Choose 4 as Step and 0 for Sleep
- Click Run
You can download the FreeCAD document file presented in this tutorial here : asm_tuto2.FCStd
Did this tutorial help you, do you have anything to share? Please open a ticket or mention something in the dedicated FreeCAD forum thread pertaining to this tutorial. You can also make a PR with your proposed changes.
Happy Assembling !