-
Notifications
You must be signed in to change notification settings - Fork 68
Tutorial: Enclosure
Level: Intermediate | Time: 10-15 minutes | Tools used: create_body, create_sketch, pad_sketch, pocket_sketch, create_enclosure_lid, create_inner_ridge, create_snap_tabs, transform_object, execute_code, export_model
Create an 80x60x30 mm electronics enclosure with 2 mm walls and a snap-fit lid. This tutorial demonstrates the enclosure skill, which orchestrates roughly 10 tool calls in sequence to build a production-ready two-part enclosure.
- Base -- a hollow rectangular box with an inner ridge near the top
- Lid -- a flat slab with a downward-facing lip that seats inside the base, plus snap tabs on the exterior
- Both parts fit together with snap-fit retention and can be 3D-printed without supports
- Switch to the FreeCAD AI workbench
- Confirm Act mode is enabled in settings
- Create a new document: File > New
- Make sure you have a capable model selected (the enclosure skill uses 15-20 tool turns)
Type in the chat panel:
/enclosure 80x60x30mm, 2mm walls, snap-fit lid
This activates the built-in enclosure skill. The AI reads the skill definition and begins the multi-step construction automatically.
The AI executes the following steps. You do not need to type anything -- just watch the model build up in the viewport.
create_body(label="EnclosureBase")
An empty Body appears in the model tree.
create_sketch(
body_name="EnclosureBase",
plane="XY",
geometries=[{type: "rectangle", x: 0, y: 0, width: 80, height: 60}]
)
pad_sketch(sketch_name="Sketch", length=30)
A solid 80x60x30 block appears.
create_sketch(
body_name="EnclosureBase",
plane="XY",
offset=30,
geometries=[{type: "rectangle", x: 2, y: 2, width: 76, height: 56}]
)
pocket_sketch(sketch_name="Sketch001", length=28)
The block becomes a hollow box with 2 mm walls and a 2 mm floor at the bottom. The sketch is placed at the top face (offset=30) and the pocket cuts downward 28 mm, leaving the floor intact.
Why offset=30? Placing the pocket sketch at z=0 and cutting upward would leave no floor. By starting from the top and cutting down, the bottom 2 mm remains solid. See FAQ for more on pocket direction.
create_enclosure_lid(
base_body_name="EnclosureBase",
clearance=1.0,
lip_height=3
)
A second Body appears with a flat slab and a downward lip that fits inside the base cavity. The clearance parameter controls the gap between lid lip and base walls for a good snap fit.
transform_object(
object_name="EnclosureLid",
translate_z=27
)
The lid moves up to sit on top of the base (30 mm total height minus 3 mm lip height = 27 mm).
create_inner_ridge(
body_name="EnclosureBase",
z_height=28
)
A small ridge appears on the inside walls of the base near the top. This ridge catches the lid lip to provide vertical retention.
create_snap_tabs(
body_name="EnclosureLid"
)
Small snap-fit tabs appear on the exterior of the lid. These flex outward during insertion and click over the inner ridge.
execute_code(code="...")
All Sketcher objects are hidden so the tree view is clean.
Now examine what was built:
- Model tree -- expand both Bodies to see all features (Pad, Pocket, Lid, Ridge, SnapTabs)
- Toggle visibility -- click the eye icon next to EnclosureBase or EnclosureLid to view each part separately
- Check the fit -- with both visible, the lid should sit on top of the base with the lip extending down into the cavity
-
Measure -- type
Measure the bounding box of EnclosureBaseto verify outer dimensions
For 3D printing, you want separate files for each part:
Export EnclosureBase to /tmp/base.step and EnclosureLid to /tmp/lid.step
Or for STL:
Export EnclosureBase to /tmp/base.stl and EnclosureLid to /tmp/lid.stl
STEP is preferred if your slicer supports it, because it preserves curved surfaces exactly.
| Part | Description |
|---|---|
| Base | Hollow rectangular box. Open at the top. 2 mm walls and floor. |
| Lid | Flat slab with a downward-facing lip. The lip fits inside the base cavity. |
| Inner ridge | A thin ledge on the inside walls of the base, near the top. Provides a catch surface for the lid. |
| Snap tabs | Small flexible tabs on the outside of the lid lip. They deflect inward during insertion and snap over the ridge. |
After the enclosure is built, you can make modifications by typing in the chat:
Make a 100x80x40 enclosure with 3mm walls
Start a new document and invoke the skill again with different numbers.
Add a grid of 3mm ventilation holes on the left side of the base
The AI will use create_sketch with circles and pocket_sketch to cut through the wall.
Add M3 screw posts in the four corners of the base, 5mm from each edge
The AI will create cylindrical bosses with appropriately sized bore holes.
Cut a 10x5mm slot in the back wall of the base for a USB cable
| Concept | Details |
|---|---|
| Skills | Predefined multi-step patterns activated with /skill_name
|
| Multi-body modeling | Base and lid are separate Bodies in one document |
| Pocket offset | Placing a pocket sketch at the top face ensures correct direction |
| Snap-fit design | Inner ridge on base + snap tabs on lid = tool-free retention |
| Multi-step construction | The AI chains 8+ tool calls to build a complete assembly |
- Print the enclosure and test the snap fit
- Customize with screw posts or cutouts
- Move on to Tutorial: Gear for an advanced parametric modeling task