Maker.io main logo

Intro to FreeCAD Part 3: Shape Binders, Expressions, and Spreadsheets

2025-01-09 | By ShawnHymel

3D Printing 3D Printer

In previous tutorials, we explored creating simple parts using FreeCAD's Sketcher and Part Design workbenches. Now, we'll advance to building assemblies with multiple bodies that fit together seamlessly. Specifically, we'll design a simple keepsake box with a lid that slides onto a base. Additionally, we'll demonstrate how to import a STEP file and use it as reference geometry to create a mounting plate or enclosure. If you have access to a 3D printer, you can bring these designs to life for your own projects.

Let's dive in!

1. Setting Up Global Parameters with Spreadsheets

Using a spreadsheet in FreeCAD allows you to define global parameters that can be referenced throughout your design. This makes your model parametric and easily adjustable.

Steps:

  • Create a New Document:
    • Open FreeCAD.
    • Close any previous documents.
    • Go to File > New.
  • Switch to Spreadsheet Workbench:
    • Select Spreadsheet from the workbench selector.
  • Create a New Spreadsheet:
    • Click the New Spreadsheet icon.
    • Rename the spreadsheet to globals by right-clicking on it in the tree view and selecting Rename.
  • Define Parameters:
    • In column A, list the parameter names:
      • length
      • width
      • base_height
      • lid_height
      • fillet
      • thickness
      • gap
    • In column B, enter the corresponding values.
      • 60 mm (length)
      • 40 mm (width)
      • 10 mm (base_height)
      • 10 mm (lid_height)
      • 4 mm (fillet)
      • 2 mm (thickness)
      • 0.2 mm (gap)
    • Note: Adjust these values as desired.
  • Assign Aliases:
    • Right-click on each cell in column B.
    • Select Properties > Alias.
    • Assign the alias matching the parameter name (e.g., cell B1 alias is length).

Intro to FreeCAD Part 3: Shape Binders, Expressions, and Spreadsheets

2. Designing the Box Base

We'll use the Part Design workbench to create the base of the box.

Steps:

  • Switch to Part Design Workbench:
    • Select Part Design from the workbench selector.
  • Create a New Body:
    • Click the Create Body icon.
  • Create a New Sketch:
    • Click the Create Sketch icon.
    • Select the XY plane.
  • Draw the Base Rectangle with Fillets:
    • Use the Rectangle tool to draw a rectangle centered around the origin.
    • Use the Fillet tool to round all four corners.
    • Apply Equal Constraint to all fillets to keep them the same size.
  • Constrain the Sketch:
    • Set Length and Width:
      • Use the Dimension tool.
      • Click on opposing points of the rectangle.
      • Enter expressions referencing the spreadsheet (enter ‘=’ or click on the small equation editor icon):
        • Length: <<globals>>.length
        • Width: <<globals>>.width
    • Set Fillet Radius:
      • Click on a fillet arc.
      • Set radius: <<globals>>.fillet
    • Center the Sketch:
      • Use the Symmetry Constraint to center the rectangle around the origin.

    Intro to FreeCAD Part 3: Shape Binders, Expressions, and Spreadsheets

    • Pad the Sketch:
      • Click Close to exit the sketch.
      • With the sketch selected, click the Pad icon.
      • Set the pad length: <<globals>>.base_height.

    Intro to FreeCAD Part 3: Shape Binders, Expressions, and Spreadsheets

    • Create outer lip:
      • Create a sketch on top of the box
      • Create a rounded rectangle
      • Make it symmetrical about the origin
      • Give it the following dimensions:
        • Length: <<globals>>.length - <<globals>>.thickness
        • Width: <<globals>>width - <<globals>>.thickness
        • Fillet radius: <<globals>>fillet - <<globals>>.thickness / 2
      • Give each of the dimensions names:
        • Length: lip_length
        • Width: lip_width
        • Fillet: lip_fillet
    • Create inner lip:
      • Create another rounded rectangle inside the first one
      • Make it symmetrical about the origin
      • Give it the following dimensions:
        • Length: <<globals>>.length - 2 * <<globals>>.thickness
        • Width: <<globals>>width - 2 * <<globals>>.thickness
        • Fillet radius: <<globals>>fillet - <<globals>>.thickness

      Intro to FreeCAD Part 3: Shape Binders, Expressions, and Spreadsheets

      • Pad the lip
        • Select the previous sketch, pad 3 mm
      • Create pocket sketch
        • Create a new sketch on the top of the original box base
        • Use the external geometry tool to bring in parts of the inner lip (should create pink dashed lines denoting external reference geometry)
        • Draw a rounded rectangle
        • Set the sides and fillet to be equal to the external geometry
        • Set the rounded rectangle to be symmetrical about the origin
        • When the sketch is fully constrained, close out of the sketch

      Intro to FreeCAD Part 3: Shape Binders, Expressions, and Spreadsheets

      • Create a pocket
        • Select the previous sketch
        • Click the Pocket tool
        • Set the pocket depth: <<globals>>.base_height - <<globals>>.thickness

Intro to FreeCAD Part 3: Shape Binders, Expressions, and Spreadsheets

3. Creating the Lid

We'll create a lid that fits snugly over the base using a second body and a sub-shape binder.

Steps:

  • Create a New Body for the Lid:
    • Click the Create Body icon.
    • Rename this body to lid by right-clicking and selecting Rename.
  • Create a Sub-Shape Binder:
    • Make sure lid is the active body.
    • Select the base body in the tree view.
    • Click the SubShapeBinder icon (green icon).
    • This creates a reference of the base in the lid body.

Intro to FreeCAD Part 3: Shape Binders, Expressions, and Spreadsheets

  • Create the Lid Sketch:
    • Offset the sketch (rather than sketching directly on the sub-shape binder)
      • Click Create Sketch.
      • Select the XY plane.
      • After creating the sketch, adjust its position:
      • In the Property panel, under Attachment > Position, set Z to <<globals>>.base_height + globals.gap.
  • Draw the Lid Profile:
    • Use the Rounded Rectangle tool to match the base's outer dimensions.
    • Make it symmetrical about the origin
    • Use the external geometry tool to bring in the outermost lines/fillet from the base sub-shape binder as reference lines
    • Set the top line, left line, and fillet to be equal to the external geometry

Intro to FreeCAD Part 3: Shape Binders, Expressions, and Spreadsheets

  • Pad the Lid Sketch:
    • Exit the sketch.
    • Select the sketch and click Pad.
    • Set the pad length: <<globals>>.lid_height.
  • Create Shell
    • Click the bottom face of the lid
    • Click the Thickness tool
      • Set the thickness: <<globals>>thickness
      • Click OK

Intro to FreeCAD Part 3: Shape Binders, Expressions, and Spreadsheets

  • Create the Inner Lip of the Lid:
    • Create a new sketch on the bottom face (outer wall bottom face) of the lid
    • Draw a rounded rectangle for the lip that will fit over the base's lip.
    • Use expressions to set dimensions:
      • Length: Sketch001.Constraints.lip_length + 2 * <<globals>>.gap
      • Width: Sketch001.Constraints.lip_width + 2 * <<globals>>.gap
      • Fillet: Sketch001.Constraints.lip_fillet + <<globals>>.gap
    • Pocket the Sketch:
      • Exit the sketch.
      • Select the sketch and click Pocket.
      • Set the pocket length: Pad001.Length
    • Change lid appearance
      • Right-click on the lid in the Tree View, select Appearance
      • Change color via Custom appearance > Ambient color
      • Change the Transparency with the slider in the Task Pane

Intro to FreeCAD Part 3: Shape Binders, Expressions, and Spreadsheets

4. Adding Chamfers and Fillets

Adding chamfers and fillets enhances the aesthetic and functionality of your design.

Steps:

  • Click the Chamfer tool
    • Task Pane will guide you through creating chamfers
  • Select Edges for Chamfering:
    • Click on the edges you want to chamfer (e.g., bottom edges of the base).
    • Hold Ctrl to select multiple edges.
  • Apply Chamfer:
    • Click the Chamfer icon.
    • Set the chamfer size (e.g., 2 mm).
    • Click OK.

Intro to FreeCAD Part 3: Shape Binders, Expressions, and Spreadsheets

5. Exporting and 3D Printing

With your design complete, you're ready to export and 3D print. Feel free to check out our Introduction to 3D Printing series to learn more!

Steps:

  • Export Bodies as STL Files:
    • Select the base body.
    • Go to File > Export.
    • Choose STL Mesh format.
    • Name the file (e.g., keepsake_box_base.stl).
    • Repeat for the lid body.
  • Prepare for 3D Printing:
    • Open your slicing software (e.g., Cura, PrusaSlicer).
    • Import both STL files.
    • Arrange them on the print bed.
    • Adjust settings (layer height, infill, supports if needed).
    • Slice and save the G-code.
  • Print the Model:
    • Transfer the G-code to your 3D printer.
    • Begin printing and monitor the process.

Intro to FreeCAD Part 3: Shape Binders, Expressions, and Spreadsheets

Importing STEP Files for Reference

Using STEP files allows you to design enclosures or mounts that fit existing components like a Raspberry Pi.

Steps:

  • Download a STEP File:
    • Visit GrabCAD, go to Library, and search for your component (e.g., Raspberry Pi).
    • Download the STEP file.
  • Import the STEP File into FreeCAD:
    • Go to File > Import.
    • Select the downloaded STEP file.
    • Wait for the import to complete.
  • Adjust Orientation:
    • If the model isn't oriented correctly:
      • Right-click on the imported part in the tree view.
      • Select Transform.
      • Rotate it as needed.
  • Create a SubShapeBinder:
    • Create a new body for your enclosure or mount.
    • With the new body active, select the imported part (e.g., PCB)
    • Click the SubShapeBinder icon.
    • Hide the original imported part.
  • Create Sketches Using Reference Geometry:
    • Use the Sketcher to create mounting holes or outlines.
    • Use the External Geometry tool to reference edges from the SubShapeBinder.

Intro to FreeCAD Part 3: Shape Binders, Expressions, and Spreadsheets

  • Design Your Enclosure or Mount:
    • Create pads, pockets, and other features as needed.
    • Ensure all dimensions are accurate for a proper fit.

Challenge: Create a Mounting Plate

Now that you've learned how to use STEP files and SubShapeBinders, try designing a mounting plate for one of your development boards.

Intro to FreeCAD Part 3: Shape Binders, Expressions, and Spreadsheets

Guidelines:

  • Choose a Board: Arduino, Raspberry Pi, or any other PCB.
  • Import a STEP File: Find and import the STEP file of your board.
  • Design the Mount:
    • Use the board's mounting holes as references.
    • Create a plate with pegs or holes to secure the board.
  • Add Personal Touches:
    • Incorporate design elements like logos or text.
    • Consider adding a snap-on lid or cover.
  • Share Your Creation:
    • Take a screenshot or photo of your design.
    • Share it on social media with the hashtag #DKFreeCAD.
    • Tag relevant accounts to showcase your work.

8. Conclusion

Congratulations! You've advanced your FreeCAD skills by learning how to work with multiple bodies, create assemblies, and use external references like STEP files. These techniques are invaluable for designing complex projects and ensuring your parts fit together perfectly.

Next Steps:

  • Experiment with more complex assemblies.
  • Explore additional FreeCAD workbenches for advanced features.
  • Stay tuned for the next tutorial, where we'll dive into creating mounting holes and using heat-set inserts.

Happy designing!

制造商零件编号 KT-PR0058-BS1MLRP
TAZ SIDEKICK LE RED EDITION
LulzBot
制造商零件编号 SC0022
SBC 1.2GHZ 4 CORE 1GB RAM
Raspberry Pi
Add all DigiKey Parts to Cart
Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.