How to Drive FreeCAD Dimensions with a Spreadsheet
Using a spreadsheet to drive dimensions in FreeCAD allows you to create fully parametric, easily configurable 3D models. This guide covers how to set up the Spreadsheet Workbench, assign cell aliases to represent design variables, link those values to sketch constraints and Part Design features using the Expression Engine, and dynamically update your model by simply editing the spreadsheet.
Step 1: Create a Spreadsheet
- Open your existing FreeCAD project or create a new one.
- In the workbench dropdown menu, select the Spreadsheet workbench.
- Click the Create spreadsheet icon. A new object
named
Spreadsheetwill appear in the Model tree. - Double-click the
Spreadsheetin the tree view to open the spreadsheet editor tab.
Step 2: Define Parameters and Aliases
FreeCAD references spreadsheet data using cell aliases rather than standard cell coordinates (like A1 or B2), ensuring references remain intact if rows or columns shift.
- In column A, type descriptive names for your parameters (e.g.,
Length,Width,Height,HoleDiameter). - In column B, enter the corresponding numeric values with optional
units (e.g.,
50 mm,30 mm,15 mm). - Right-click the cell containing the numeric value (e.g., cell B1) and select Properties.
- In the dialog, navigate to the Alias tab.
- Enter a valid alias name (e.g.,
Length). The alias must contain only letters, numbers, and underscores, and cannot start with a number. - Click OK. The cell background will turn yellow, confirming an alias has been assigned.
- Repeat this process for all parameter values.
Step 3: Link Dimensions in a Part Design Sketch
- Switch to the Part Design workbench.
- Open an existing sketch or create a new sketch on your desired plane.
- Apply a dimensional constraint (such as horizontal distance, vertical distance, or radius).
- In the constraint input window, click the small blue f(x) icon on the right side of the value field to open the Formula Editor.
- In the formula field, type
Spreadsheet.AliasName(for example,Spreadsheet.Length). As you type, FreeCAD will provide auto-complete suggestions. - Click OK to close the Formula Editor, then click OK to close the constraint dialog. The dimension constraint will turn orange, indicating it is driven by an external expression.
Step 4: Link 3D Features (Pad, Pocket, Revolve)
Spreadsheet values can also directly drive 3D operation parameters, such as the extrusion depth of a Pad.
- Select your sketch and click Pad (or double-click an existing Pad in the Model tree).
- In the Tasks panel, locate the Length field.
- Click the blue f(x) icon next to the input field.
- Enter
Spreadsheet.Height(or your defined alias) into the Formula Editor. - Click OK, then click OK on the Pad dialog to complete the operation.
Step 5: Update the Model Dynamically
- Double-click the
Spreadsheetin the Model tree to open it. - Change any numeric value that has an alias assigned to it.
- Switch back to your 3D view. If the model does not update immediately, press Ctrl + R (or select Edit > Refresh) to recompute the document with the new dimensions.