Skip to content

Tutorial: Enclosure

alf edited this page Feb 23, 2026 · 4 revisions

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

Goal

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.

What You Will Build

  • 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

Steps

Step 1: Set Up

  1. Switch to the FreeCAD AI workbench
  2. Confirm Act mode is enabled in settings
  3. Create a new document: File > New
  4. Make sure you have a capable model selected (the enclosure skill uses 15-20 tool turns)

Step 2: Invoke the Enclosure Skill

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.

Step 3: Watch the Construction

The AI executes the following steps. You do not need to type anything -- just watch the model build up in the viewport.

3a. Create the base body

create_body(label="EnclosureBase")

An empty Body appears in the model tree.

3b. Sketch and pad the outer shell

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.

3c. Hollow the interior

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.

3d. Create the lid

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.

3e. Position the lid

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).

3f. Add the inner ridge

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.

3g. Add snap tabs

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.

3h. Hide construction sketches

execute_code(code="...")

All Sketcher objects are hidden so the tree view is clean.

Step 4: Inspect the Result

Now examine what was built:

  1. Model tree -- expand both Bodies to see all features (Pad, Pocket, Lid, Ridge, SnapTabs)
  2. Toggle visibility -- click the eye icon next to EnclosureBase or EnclosureLid to view each part separately
  3. Check the fit -- with both visible, the lid should sit on top of the base with the lip extending down into the cavity
  4. Measure -- type Measure the bounding box of EnclosureBase to verify outer dimensions

Step 5: Export Both Parts

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.

Enclosure Anatomy

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.

Customization Ideas

After the enclosure is built, you can make modifications by typing in the chat:

Change dimensions

Make a 100x80x40 enclosure with 3mm walls

Start a new document and invoke the skill again with different numbers.

Add ventilation holes

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 screw posts

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.

Add a cable cutout

Cut a 10x5mm slot in the back wall of the base for a USB cable

What You Learned

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

Next Steps

  • 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

Clone this wiki locally