interference
Determine if two named objects intersect in 3D space, returning interference status, overlap volume, and bounding region.
Instructions
Check whether two named objects (from show()) intersect. Returns interferes (bool), volume (mm³ of overlap), and bounds of the interference region.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| object_a | Yes | ||
| object_b | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- Helper that computes the boolean intersection of two shapes and returns (interferes, volume, bounds).
def _compute_interference(shape_a: Any, shape_b: Any) -> tuple: try: inter = shape_a & shape_b vol = inter.volume except Exception: return (False, 0.0, None) if vol < 1e-6: return (False, 0.0, None) bb = inter.bounding_box() return (True, vol, { "xmin": bb.min.X, "xmax": bb.max.X, "ymin": bb.min.Y, "ymax": bb.max.Y, "zmin": bb.min.Z, "zmax": bb.max.Z, }) - Main tool handler: validates object names from session, computes interference via boolean intersection, returns JSON with interferes/volume/bounds.
def interference(session, object_a: str, object_b: str) -> str: for name in (object_a, object_b): if not name or name not in session.objects: raise ValueError(f"Unknown object '{name}'. Registered: {list(session.objects.keys())}") shape_a = session.objects[object_a] shape_b = session.objects[object_b] interferes, volume, bounds = _compute_interference(shape_a, shape_b) if not interferes: return json.dumps({"interferes": False, "volume": 0.0}, indent=2) return json.dumps({ "interferes": True, "volume": volume, "bounds": bounds, }, indent=2) - src/build123d_mcp/server.py:66-69 (registration)MCP tool registration: decorates the interference function as a @mcp.tool, delegates to the session's interference method.
@mcp.tool() def interference(object_a: str, object_b: str) -> str: """Check whether two named objects (from show()) intersect. Returns interferes (bool), volume (mm³ of overlap), and bounds of the interference region.""" return _session.interference(object_a, object_b) - src/build123d_mcp/worker.py:255-260 (handler)Session proxy method on the Worker class that delegates the interference call to the worker subprocess via IPC with a 30-second timeout.
def interference(self, object_a: str, object_b: str) -> str: return self._call( "interference", {"object_a": object_a, "object_b": object_b}, self._INTERFERENCE_TIMEOUT, ) - src/build123d_mcp/worker.py:70-72 (registration)Worker dispatch: routes the 'interference' operation to the actual implementation in tools/interference.py.
if op == "interference": from build123d_mcp.tools.interference import interference return interference(session, **args)