Add Text
add_textUse this when you need to author text into a kernelCAD script before the last top-level return. One authoring path, selected by mode:
'sketch' — insert a sketch.text(...) call. The emitted sketch is chainable: pair with subsequent .extrude(...) / cut(...) edits to land an engraved or raised text feature.
'emboss' — insert a
<shape>.embossText({...})chained call onto an existing Shapetarget. Use for engraved brand text on faces (Ray-Ban temple, CE mark, model number).depth > 0raises text out of the face;depth < 0engraves text into the face. Lowers via replicad drawText → sketchOnFace → extrude → fuse|cut. Default font is the runtime-bundled Liberation Sans. Side-effect-free; returns the modified code plus diagnostics from re-evaluating. Each mode fails closed on its own missing required params.
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": {
"mode": "<mode>",
"code": "<code>"
},
"name": "add_text"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | The .kcad.ts source code. | |
| face | No | mode:'emboss' — target face — canonical name ('top'/'bottom'/'left'/'right'/'front'/'back') or label. | |
| font | No | mode:'sketch' — optional logical font name or .ttf file path; defaults to bundled Liberation Sans. | |
| mode | Yes | Which text-authoring path to use. | |
| size | No | mode:'sketch'|'emboss' — glyph cap height in mm (positive finite). | |
| align | No | mode:'sketch' — horizontal alignment relative to position (default left); mode:'emboss' — relative to the UV anchor (default center). | |
| depth | No | mode:'emboss' — signed extrusion depth in mm: positive emboss out, negative engrave in. Must be non-zero. | |
| target | No | mode:'emboss' — variable name of the Shape to chain onto (inserted verbatim). | |
| bind_as | No | mode:'sketch' — emits `const <bind_as> = sketch.text(...)`; mode:'emboss' — emits `const <bind_as> = <target>.embossText(...);`. | |
| content | No | mode:'sketch' — text content (UTF-8, non-empty, non-whitespace). | |
| anchor_u | No | mode:'emboss' — U anchor in [0, 1] face-local (0=umin, 0.5=centre, 1=umax). Default 0.5. | |
| anchor_v | No | mode:'emboss' — V anchor in [0, 1] face-local. Default 0.5. | |
| position | No | mode:'sketch' — [x, y] anchor in mm. Default [0, 0]. | |
| rotation | No | mode:'sketch' — CCW rotation in degrees around position (default 0); mode:'emboss' — CCW rotation in the face tangent plane (default 0). | |
| scale_mode | No | mode:'emboss' — Drawing.sketchOnFace scaling mode. Default original. | |
| font_family | No | mode:'emboss' — optional logical font name or .ttf file path; defaults to bundled Liberation Sans. | |
| text_content | No | mode:'emboss' — text content (UTF-8, non-empty, non-whitespace). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||