Set Parameter
set_paramUse this when you need to edit a param() default value in a kernelCAD script. Returns the modified code as text plus diagnostics from re-evaluating the result. Caller persists the new code via standard file-write tools (this tool has no side effects). With preview: true it builds the edit in a scratch session instead and returns the diff_geometry summary plus the requirements-ledger and S1 binding diffs (which requirements flip, which margins shrink, which selectors moved or re-bound), without touching the active session, source, revision or caches. A preview whose revised build fails returns ok:false and no diff. Inspect after.requirementsOk to see whether the edit preserves declared intent; preview.ok only says the preview could be computed.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | The .kcad.ts source code. | |
| preview | No | S6 edit preview: evaluate the edit in a scratch session and return geometry + requirements-ledger + S1 binding diffs. Writes nothing. Default false (the normal source-edit result). | |
| new_value | Yes | The new default value. A number for a numeric param (e.g. 12.5), a string expression evaluated in the script (e.g. "width/2 + 3") or a choice/colour, or true/false for a boolean param. | |
| param_name | Yes | The string literal name of the param (first arg to param()). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||