Add Variable Sweep
add_variable_sweepUse this when you need an organic swept solid whose cross-section changes along its length — a tapering body, horn, bottle, handle, ring band, fairing, or duct — authored as a variable-section sweep along a spine. Inserts variableSweep(spine, sections, opts?) into the .kcad.ts code immediately before the last top-level return (an empty code starts a new script that returns the sweep). Spine: EITHER spine_points ([[x,y,z], ...] in mm, interpolated with spline3d; spine_closed: true closes the loop for a ring) OR spine_binding (an existing Curve3D / Sketch / Vec3[] variable). Each section: t in [0, 1] plus a profile — inline radius (circle) or width + height (rectangle), or profile_binding (an existing Sketch); profiles are centred on the spine and turned to face along it. Sections are strictly increasing in t, first t=0, last t=1 (omit t on every section to space them evenly). On a closed spine t=1 is the seam and reuses the t=0 profile. Example: { code, spine_points: [[0,0,0],[0,10,30],[0,0,60]], sections: [{ t: 0, radius: 8 }, { t: 0.5, radius: 10 }, { t: 1, radius: 4 }] }. Returns the modified code, diagnostics from re-evaluating it, and sweep { volumeMm3, bbox } measured from the built solid (ok:false when the sweep built nothing). The result is a Shape binding: return it, or chain .union(...) etc. via add_feature. Orientation is not exposed by this MCP tool until runtime orientation support is wired. Side-effect-free.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | The .kcad.ts source code ("" for a new script). | |
| closed | No | Optional closed-sweep flag. | |
| sections | Yes | Varying cross-sections along the spine; at least 2 entries, strictly increasing in `t`, first t=0, last t=1. | |
| continuity | No | Inter-section continuity; default 'C1'. | |
| binding_name | No | JS const name for the new Shape binding (default: _sweep_<N>). | |
| spine_closed | No | With spine_points: close the spline into a loop (ring band, loop handle). | |
| spine_points | No | Inline spine: at least 2 [x, y, z] points in mm, interpolated with spline3d. Use this OR spine_binding. | |
| spine_binding | No | Existing variable name for a Curve3D / Sketch / Vec3[] declared earlier in the source. Use this OR spine_points. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||