Variant Link: Difference between revisions

From FreeCAD Documentation
Line 33: Line 33:
'''TODO:''' Finish tutorial for how to do this.
'''TODO:''' Finish tutorial for how to do this.


1. Create a new spreadsheet with a heading row, skip a row underneath (you'll see why later), and add parameters for M10 and M12 in row #3 and #4.
# Create a new spreadsheet with a heading row, skip a row underneath (you'll see why later), and add parameters for M10 and M12 in row #3 and #4.
2. Use the Part Design workbench to create a body and sketch for the hex nut.
# Use the Part Design workbench to create a body and sketch for the hex nut. Pad the sketch.


[[File:Variant-link-example-hex-nut-sketch.png]]
[[File:Variant-link-example-hex-nut-sketch.png]]

Revision as of 02:06, 12 October 2022

Introduction

With the release of FreeCAD 20, in particular configuration tables, a powerful new pattern, so called "variant links" become possible.

"Variant links" build upon Link to vary sets of parameters for a given object at runtime.

Prior to this, you could parameterize objects with techniques such as spreadsheets, but multiple varied instances of that object couldn't coexist at the same time unless you resorted to techniques like copying files or objects which creates maintenance issues.

"Variant links" make the maintenance of such variants, and ability to toggle between them easy and maintainable.

Example

To gain a better idea of "variant links", consider the following example.

Imagine a simple hexagonal nut with a "major" diameter of 10mm (M10). We can reuse the same design, create a link, and then vary certain parameters to create an M12 hexagonal nut.

For our example, we can describe the differences between these two variants with 3 parameters:

  1. diameter of the center hole
  2. width across the corners
  3. and thickness.

The particular parameter values for our variants are described in the below table.

Variant Diameter WidthAcrossCorners Thickness
M10 10 18.48 8.4
M12 12 20.78 10.8

TODO: Finish tutorial for how to do this.

  1. Create a new spreadsheet with a heading row, skip a row underneath (you'll see why later), and add parameters for M10 and M12 in row #3 and #4.
  2. Use the Part Design workbench to create a body and sketch for the hex nut. Pad the sketch.

Notes to original and future authors

This is a collection of thoughts, intended to be worked on, refined, and incorporated into this page which is very much a work in progess.

  • I would like to mention a key point made by realthunder here explaining the difference between using a Link vs. SubShapeBinder for variant links:

Instead of duplicating the linked object with all its hierarchy, the [SubShapeBinder] will make a flattened copy of the mutated object. Another difference to Link is that the [SubShapeBinder] will sync any changes of the original object back to the copy even if the configurations are different, while for Link, once copied, the two objects become independent.

  • Another key point is that although built upon links, variant links are not "cheap" like normal links[1], as they create copies of the original object. Guidance is provided by realthunder in the forums here and needs to be concisely summarized and organized into this page:

Additionally, when using Link for alternative configurations, you'll need to realize that it makes a copy of the original object. ... it would be better to create a single 'variant' link for each [variant] to avoid unnecessary duplicates. Or better, use SubShapeBinder ... And again, create one [SubShapeBinder] for each configuration.