Add Part
add_partUse this when you need to add a part to an assembly. Durably insert const <binding> = <assembly>.part(partName, shapeExpression, opts?) before the final top-level return in a kernelCAD source string. Returns modified source plus diagnostics from re-evaluating it. Side-effect-free: caller persists the returned source.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| at | No | Optional [x, y, z] assembly placement. | |
| code | Yes | The .kcad.ts source code. | |
| part_name | Yes | Assembly-unique part name. | |
| binding_name | No | Optional JS const name for the returned AssemblyPartRef. Defaults to a part-name-derived identifier. | |
| assembly_binding | Yes | JS identifier bound to assembly(...), e.g. "arm". | |
| shape_expression | Yes | JS expression for the Shape to pass to assembly.part, inserted verbatim. |
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). |