Hecatronic
831 words
4 minutes
Creating FreeCad variant parts
2024-04-08

One of the features I’ve found handy within Cad packages such as Solidworks is the use of something called Variant Parts or part configurations.
What this amounts to is having a single part but where you can select multiple options from a drop down configuration entry to change the diameter or length.

It turns out you can do this with FreeCad, although it’s not that obvious so I’ve detailed the steps below.

Creating the Part#

For this example I’m going to create an OpenBuilds Aluminum Spacer part
This comes in a range of lengths including

  • Metric: 3mm, 6mm, 9mm, 10mm, 20mm, 13.2mm, 20mm, 35mm, 40mm
  • Imperial: 0.125inch, 0.25inch, 1.5inch

Openbuilds have made they’re STEP files for they’re parts available over here Link

Creating a Sketch#

First lets create a simple sketch.

  • Open up FreeCad
  • Select the PartDesign workbench
  • Select New
  • Create Body
  • Create Sketch
  • Select the X-Y Plane

Create two circles based on the origin.
The outer diameter being 10mm, the inner diameter being 5.1mm

Adding a Pad#

Next add a Pad to the sketch of around 6mm or so. This pad is what we’ll setup as a configurable option later on.

Rename the Part#

Save the part as a file under the name of something like OB-Aluminum-Spacer.
Rename the Body to the same as well in case we want to use this part within an assembly later on

Setting up the Part configuration#

Next we’re going to setup the Pad or thickness / height of the object as a predefined list of options we can pick from.

Creating a Part Spreadsheet#

  • Select the Spreadsheet workbench
  • Select the Spreadsheet Menu and Create Spreadsheet
  • Rename the spreadsheet to something like PartConfigs

Within the spreadsheet we’re going to create three columns.

  • The first will be named Variant
    This is the name of the drop down configuration option you will pick.
  • The second will be named Length mm
    This is what will be fed into the Padding of the part.
  • The third will be named Length inch
    This value will be calculated into mm using a cell forumlae

Creating a Configuration Table#

  • Make sure there is an empty row between the heading and the values underneath.
  • The first column needs to only contain string values for the drop down selection.
    so if entering in 3 mm for example this will evaluate to =3 mm, make sure to change this to '3mm instead (putting a single quote in front) so that it’s seen as a string.
  • For the second column this should be recognised as a number which is what we want.
    For the calculation from inches to mm this will be something like =C13 * 25.4 mm for the forumlae

Right click in the spreadsheet and select Configuration Table.

For the range we want to select the empty space above as the starting row
and the bottom of the list as the end. So in this example I’m using:

  • Range: A2-B13
  • Property: Body.ConfigLength

Creating an Alias#

After creating the configuration table, the cell B2 is now special in that it’s value will change based on the drop down option that is picked for the part.

  • Create an Alias for cell B2 and call it PartLength

Next we’re going to use that Alias (which will change based on which option is picked) in the Pad settings to alter the length of the part. We can also do this for sketch dimensions as well.

  • Open up the Pad settings on the part.
  • For the Length click the small button to open up the forumlae window.
  • Enter in Spreadsheet.PartLength, this should match up with the alias we created before.
    It also auto completes as we’re typing it in

Changing the Part Configuration#

If we select the Body of the part we can now change it’s length using the drop down configuration option.
(Note you have to click away from the setting for the change to take affect).

Using the Part within an Assembly#

In some cases you may want to use multiple instances of the same part within a single Assembly but with different instances having different lengths or configuations.

Creating an Assembly#

First lets create a new Assembly.
I’d recommend using the Assembly3 Addon for something similar to Solidworks in terms of using constraints to join parts together

  • Select the Assembly3 workbench
  • Select the File -> New menu option
  • Select the Assembly3 -> Create Assembly menu option
  • Save the assembly under a new name

Adding in the Part#

Let’s add the spacer part we’ve been working on so far

  • Open up the Spacer part using File -> Open (you can also just drag it in from the file explorer)
  • Select the Body of the spacer and drag it to the Parts section of the Assembly
  • This should result in multiple instances of the part being added

Next we want to move one of the instances away from the first

  • Select one of the instances
  • Select Assembly3 -> Axial Move Part
  • Drag the first instance away from the second

If we try and change the config option to a different length it will change the length on all the attached parts within the assembly. To prevent this from happening we can change an option called Link Copy on Change.

  • Set this option to Owned for all attached parts within the assembly

You should now be able to assign a different option to each part

  • For an explanation of each option Link
Creating FreeCad variant parts
https://www.hecatron.com/posts/2024/freecad-variants/
Author
Hecatronic
Published at
2024-04-08