Add Variable Sweep
add_variable_sweepUse this when you need to author a variable-section sweep along a spine. Insert a variableSweep(spine, sections, opts?) declaration into the user's .kcad.ts immediately before the last top-level return. The result is a Shape — chain .translate(...), .union(...), etc. via add_feature. spine_binding references an existing variable (Curve3D / Sketch / Vec3[]) in the source; each sections[i].profile_binding references an existing Sketch. Sections must be strictly increasing in t and span [0, 1]; first t=0, last t=1. Orientation is not exposed by this MCP tool until runtime orientation support is wired. Validates every binding exists in the source via regex before inserting (fast structured error vs capture-time stack). Returns the modified code + diagnostics. Side-effect-free.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | The .kcad.ts source code. | |
| 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_binding | Yes | Existing variable name for a Curve3D / Sketch / Vec3[] declared earlier in the source. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | Yes | Whether the edit applied and re-evaluated cleanly. | |
| error | No | Failure message (present when ok is false). | |
| new_code | No | Modified .kcad.ts source (present on success). Caller persists it. | |
| diagnostics | No | Diagnostics from re-evaluating the modified source. | |
| binding_name | No | JS const name bound to the new construct (when one was created). |