Add Connector
add_connectorUse this when you need to add a mate connector to a part. Durably insert <partBinding>.connector(name, { type, origin, axis?, normal? }) before the final top-level return. Use the part binding returned by add_part. Returns modified source plus diagnostics from re-evaluation. Side-effect-free.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| axis | No | Optional [x, y, z] axis. | |
| code | Yes | The .kcad.ts source code. | |
| name | Yes | Connector name unique within the part. | |
| type | Yes | ||
| normal | No | Optional [x, y, z] normal. | |
| origin | Yes | Origin as [x, y, z] shorthand, or a structured ConnectorOrigin. | |
| part_binding | Yes | JS identifier bound to an AssemblyPartRef, e.g. "basePart". |
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). |