Export
exportUse this when you need to export geometry to a file. One exporter, selected by target:
target:'model' — export the script geometry to one file. Pass { file | code }, a required { output_path }, and { format }. Supported formats: stl (binary STL mesh), step (BREP CAD interchange), dxf (planar laser/waterjet profile from a Region or planar face), 3mf (slicer-friendly mesh with per-part colors), glb (web-viewer / AR with PBR materials), svg-drawing (third-angle engineering-drawing sheet: front/top/left + isometric views, hidden edges dashed, tangent edges thin, overall bounding-box dimensions, title block; assemblies are drawn with inter-part occlusion). Robot descriptions: urdf (tree-topology robot description), srdf (motion-planning semantics layered over the URDF), sdf-gazebo (SDFormat 1.10 with native ball joints, closed loops, and solved per-link poses). urdf and sdf-gazebo also write one meshes/.stl per link next to output_path (reported in mesh_files) — ship the whole directory to the consumer. STL exports run a watertight verify by default; failures return ok: false with export.mesh.not-watertight (open-edge count + up to 5 crack-cluster locations) but the file is still written so the broken mesh can be inspected. Optional { feature_id } selects which feature to export (default: last). Optional { options } carries per-format options bag (see the kernelcad-mcp skill for the per-format keys: dxf layers/tolerance/unit, 3mf printUnit/embedSource, glb axis/draco).
target:'part' — export solved-assembly parts as individual binary STL files in their modeled (world-frame) positions. Pass { file | code }, plus { part, output_path } for one part or { output_dir } for all parts (files land at /.stl). A watertight verify runs on every exported mesh by default and fails the call with export.mesh.not-watertight; unknown part names fail with export.part.not-found listing the valid names. Pass { no_verify: true } to skip the watertight gate. All params except
targetare forwarded verbatim; each target fails closed on its own missing required params.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | No | Inline kernelCAD script source. | |
| file | No | Path to a .kcad.ts script file. | |
| part | No | target:'part' — part name for single-part export, or 'all'. | |
| format | No | target:'model' — output file format (required for that target). | |
| target | Yes | Which exporter to run: 'model' (whole-script geometry to one file) or 'part' (per-part STLs from a solved assembly). | |
| options | No | target:'model' — optional per-format options bag. Discriminator options.format must equal top-level format. dxf: { layers?, unit?: "mm"|"cm"|"in", tolerance? }. 3mf: { printUnit?: "mm"|"cm"|"in", embedSource? }. glb: { axis?: "y-up"|"z-up", draco?: false }. svg-drawing: { sheet?: "a4"|"a3", modelName?, date? }. | |
| no_verify | No | Skip the STL watertight verify gate. | |
| feature_id | No | target:'model' — optional FeatureId to export; defaults to last. | |
| output_dir | No | target:'part' — destination directory (all-parts mode); files are <dir>/<part>.stl. | |
| output_path | No | Destination path. target:'model' — the export file (required). target:'part' — single-part .stl path. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | Yes | ||
| error | No | ||
| format | No | ||
| written | No | target:'part' — per-part export records. | |
| byte_count | No | target:'model' — file size in bytes. | |
| mesh_files | No | Per-link mesh files for urdf/sdf-gazebo exports. | |
| diagnostics | No | ||
| output_path | No | target:'model' — written file path. | |
| feature_count | No |