Add Feature
add_featureUse this when you need to insert a new feature line into a script. Insert a new feature line into a kernelCAD script before the last top-level return statement. Returns the modified code as text plus diagnostics from re-evaluating the result. Direct editing is authored here too: use body.deleteFace(faces) to heal a removed-face opening, or body.replaceFace(faces, { origin, normal }) for a parallel planar replacement; the runtime refuses any result that does not pass its single-solid BRepCheck gate. Primitives that accept faceLabels (box, cylinder, extrudeRect, extrudeCircle, extrudePolygon, extrudeRoundedRect) can receive opts.faceLabels in the inserted code — use lookup_api to see featureKindFaceLabels for the full value schema.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"code": "<code>",
"feature_code": "<feature_code>"
},
"name": "add_feature"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | The .kcad.ts source code. | |
| feature_code | Yes | Single-statement source line to insert. A narrow analytic G4 certificate is available only for a terminal, unlabeled 360-degree revolve followed only by finite translations, finite rotations about an axis of finite positive squared length, uniform scales by one finite positive factor, and reflections across a cardinal plane with a finite optional offset, with no downstream consumers, using a move + 2–128 three-point arcs + close profile. Exact dyadic checks require the move point and a later endpoint to be antipodal, every endpoint and midpoint on the same exactly representable circle, and exact cyclic ordering that proves the arcs partition it once without gaps or overlaps; the circle must satisfy R > r > 0. The lowerer constructs one OCCT analytic torus face, independently enumerates both closed periodic self-seams, measures both stored p-curve branches at finite D0–D4 stations within edge-tolerance limits, and requires a valid nonempty one-solid result with finite positive volume. An outward-rounded torus period bound covers the full seam domains; station readings are conformance checks, not the proof. A rotated, uniformly scaled or reflected result is certified only when its final torus support frame, read from the built face and normalized by the product k of the scale factors, is within 2^-30 of an orthonormal frame and of the source tube ratio; the bounds carry that distortion. Every certificate is conditional on unproved assumptions: an OCCT TORUS support evaluates the closed-form torus formula, and, for a rotated, scaled or reflected result, OCCT evaluates the torus derivatives at u = v = 0 with relative error at most 2^-40. Non-uniform scale, malformed reflection planes, face labels, downstream consumers, near-circular, axis-touching/crossing, partial-turn, malformed, incomplete, and otherwise unsupported cases remain sampled or uncertified; nine stations alone do not prove continuity. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||