Skip to main content
This page documents the Python surface exposed to execute_code. The import names are the upstream module names required by the compatibility layer.

Document access

Object lookup:

Object creation

Prefer create_object, create_objects, and builder MCP tools when they cover the operation.

Placement and rotation

Rotation between vectors:
Placement composition:

Spreadsheet-driven parameters

Expression binding:
Variable naming:
  • UpperCamelCase aliases: WallThickness, BoltCircleDia, PlateLength.
  • Column A label, column B value.
  • Keep rows alphabetically sorted by alias name.
  • Do not hard-code driving dimensions when a spreadsheet alias should control them.

Sketcher geometry

Construction geometry:
Common primitives:

Sketcher constraints

Position ids:
Use get_sketch before editing existing sketches. It returns geometry indices, constraint indices, construction flags, open vertices, attachment, and serialized constraints.

PartDesign feature pattern

Common features and properties:
Inspect actual property names with get_object or Python obj.PropertiesList before uncommon assignments.

Part module geometry

Boolean shape operations:
Wire, face, extrude:
Use this for unsupported geometry only. Prefer parametric PartDesign features for final editable designs.

Draft module

Use Draft for 2D construction, imported DXF/SVG cleanup, reference wires, and non-PartDesign 2D objects.

TechDraw

Prefer TechDraw MCP tools for discovery and rendering:
Python pattern:
Do not claim drawings are current unless recomputed and rendered.

Mesh

Mesh output is faceted. Do not treat mesh repair or conversion as proof of exact parametric reconstruction.

BIM / Arch

Preserve semantic type, level/storey, hosted openings, IFC metadata, and placement. Do not convert BIM objects into anonymous solids unless explicitly requested as a lossy export or diagnostic step.

Export and save

Use MCP file-save tools first. If Python export is required and the user has requested the path:
Do not write arbitrary files outside user-requested model save/export paths.

Validation in Python

Prefer MCP validators after Python execution because they return structured payloads and screenshots where available.