Cut an object along a plane and add aligned magnet holes with surface collision detection. Creates two parts with perfectly aligned holes for embedding magnets that allow the parts to snap together.
This macro cuts a 3D object along a specified plane and automatically adds aligned magnet holes to both resulting pieces. The holes are positioned with intelligent collision detection to ensure they don't break through the outer walls of the object.
This is particularly useful for:
Creating multi-part prints that snap together with embedded magnets.
Splitting large objects for smaller 3D printer beds while maintaining alignment.
Adding magnetic closure mechanisms to enclosures and cases.
Key Features:
Cut along preset planes (XY, XZ, YZ) or model datum planes.
Automatic hole placement with even distribution along the cut edge.
Surface collision detection prevents holes from breaking through walls.
Configurable hole diameter, depth, and count.
Preferred and minimum edge clearance settings.
Smart repositioning of holes when initial placement fails safety checks.
Creates PartDesign::Body objects with parametric Hole features.
This image shows a vase object in its original form, and after being cut multiple times with the macro. Magnets can then be inserted into the object, and the object can be re-assembled. This example was to create a "breakable" vase for a theatrical stage performance, but there are many other potential uses as well.
How It Works
Cutting Process:
Creates a large half-space box aligned with the cutting plane.
Uses boolean operations to split the object into two parts.
Creates PartDesign::Body containers for each half.
Hole Placement Algorithm:
Calculates hole positions evenly distributed along the cut face perimeter.
For each position, validates against BOTH parts (not just one).
Uses preferred clearance first, falls back to minimum if needed.
Checks for hole-to-hole spacing (minimum 2x diameter).
Repositions holes that fail safety checks using multiple strategies:
Reduced clearance at same position.
Increased inset from edge.
Alternative positions along the perimeter.
Safety Features:
Creates test cylinders to check if holes would break through walls.
Validates each hole against both the top and bottom parts.
Skips holes that cannot be safely placed.
Reports repositioned and skipped holes in the console.
Parameters
Parameter
Description
Default
Plane Type
"Preset Plane" (XY/XZ/YZ) or "Model Plane" (datum plane)
Preset Plane
Offset
Distance from origin for preset planes
0 mm
Diameter
Magnet hole diameter
3 mm
Depth
Hole depth from cut surface
3 mm
Number of Holes
Total holes to create
6
Edge Clearance (Preferred)
Ideal distance from hole edge to object surface
2 mm
Edge Clearance (Minimum)
Minimum acceptable clearance (used during repositioning)
0.5 mm
Requirements
FreeCAD 0.19 or later.
An object with a solid shape (Part or PartDesign body).
For model plane mode: a datum plane or object with planar faces.