compile_scad
Compile OpenSCAD code or .scad files into STL, then validate the mesh and reject floating pieces or missing libraries before printing.
Instructions
Compile OpenSCAD code into an STL file.
Takes OpenSCAD source code OR a path to a .scad file, compiles
it using the local OpenSCAD binary, and returns the path to the
generated STL. Kiln's bundled BOSL2 and MCAD libraries are on
OpenSCAD's library path (``include <BOSL2/std.scad>``).
For surface() heightmap operations (photo emboss, lithophane),
increase timeout to 600+ seconds.
Kiln checks the compiled part is joined up. A piece that floats
with nothing under it is joined to nothing and prints as a loose
part on supports, or not at all, so the make is REFUSED
(``code: "FLOATING_PIECES"``; ``error`` names the pieces, how
far they are from the nearest surface, and the fix): correct
the geometry and compile again. Separate parts that all sit on
the bed are a plate and pass; a piece held inside the part (a
ball in a cage, a pin in its knuckles) passes with a warning; a
piece that touches the rest without overlapping it is named in
``warnings``.
A compile where OpenSCAD could not find an included library, an
imported file or a module is refused too: OpenSCAD leaves that
part out and still exits cleanly, so the file would be missing
pieces. ``error`` names what was missing.
A setting the called module has no parameter for (OpenSCAD
ignores it and builds the default size) is read by the module's
own name when that is certain and a measured build confirms it:
``settings_read`` says what was read, once, and
``corrected_scad_code`` is the code built; keep that code.
Otherwise the compile is refused and ``error`` lists the
module's real settings.
Colour: pass ``color`` (a name such as ``"teal"`` or a hex) when
the user asked for one, and the preview and the 3D stage show
the part in it. Left out, a single ``color("...")`` in the
source is used. It is how the part is SHOWN; it prints in
whatever filament is loaded, and the result's ``color`` block
says so.
Round shapes: leave ``$fn`` out and Kiln cuts each curve by its
size, writing that rule into the file it compiles. Set ``$fn``
only for a deliberate polygon (``$fn = 6`` for a hexagon). A
file that sets ``$fn``, ``$fa`` or ``$fs`` at the top compiles
exactly as written, and the result's ``curve_resolution`` note
says so.
Named parts: a source may define each part as its own module and
compose them in ``module main()``, drawing nothing at the top
level; it compiles to ``main()``. Kiln keeps generated designs
this way, so a kept source compiles as it is.
When you pass ``fastener``, the result carries a
``fastener_advice`` block saying the code compiled as written
and nothing resized the hole for that fastener. Kiln raises
it once per session across every tool that can raise it. Read
its ``agent_instruction`` before repeating any of it.
Args:
goal_id: The saved goal's id from ``design_session``, so this make
is recorded against the goal and checked against it. Empty when
there is no goal.
scad_code: Valid OpenSCAD source code (provide this OR scad_path).
scad_path: Path to a .scad file (provide this OR scad_code).
timeout: Maximum compilation time in seconds (default 300).
fastener: The fastener the user named, e.g. ``"M4"`` — pass
only if they actually said one. Kiln does NOT read your
OpenSCAD looking for screw holes; guessing intent out of
geometry would be wrong often. No argument, no advisory.
color: The colour the user asked for, shown on the preview and
the stage (a name or ``#rrggbb``). Not a print setting.
motion: When the part has pieces that move against each other (a
hinge, a gearbox, a slider): how it moves, in your source's own
part names, so the reply's ``motion`` can say whether it plays
and what was found. ``{"parts": {name: [x, y, z]}}`` gives each
piece a point inside its material (millimetres, as modelled);
``"joints"`` lists ``{"parts": [stays, moves], "kind": "hinge" |
"slider" | "fixed", "axis_point", "axis_direction", and
"range": [lo, hi] or "continuous": true}``; ``"driver"`` names
the piece a hand turns or slides (leave it out when each piece
moves on its own, like drawers in a case); ``"gears"`` (optional) lists
``{"parts": [a, b], "teeth": [na, nb], "carrier": the piece
holding both axes, "inside": true when b is a ring with its
teeth inside}``. Checked with a goal (``goal_id``) on a make
Kiln's servers answer; then the stage on this computer plays it
too. Elsewhere the reply carries no ``motion``.INLINE 3D STAGE: on success this tool opens Kiln's interactive 3D stage — an inline viewer panel the user can orbit, zoom, and turn over — in hosts that render MCP Apps panels (Kiln's hosted connection attaches a browser stage link for hosts that don't). Oversized meshes are decimated automatically for the stage; the PNG preview is the floor, not the whole experience.
MAKE DOORS: design_session, Kiln's front door for making an object, is not installed here (signed in to Kiln it runs on Kiln's servers). On this install compile_scad IS the make → preview → iterate loop: make it, show the preview, iterate.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "compile_scad"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| color | No | The colour the user asked for, shown on the preview and the stage (a name or ``#rrggbb``). Not a print setting. Default: "". | |
| motion | No | When the part has pieces that move against each other (a hinge, a gearbox, a slider): how it moves, in your source's own part names, so the reply's ``motion`` can say whether it plays and what was found. ``{"parts": {name: [x, y, z]}}`` gives each piece a point inside its material (millimetres, as modelled); ``"joints"`` lists ``{"parts": [stays, moves], "kind": "hinge" | "slider" | "fixed", "axis_point", "axis_direction", and "range": [lo, hi] or "continuous": true}``; ``"driver"`` names the piece a hand turns or slides (leave it out when each piece moves on its own, like drawers in a case); ``"gears"`` (optional) lists ``{"parts": [a, b], "teeth": [na, nb], "carrier": the piece holding both axes, "inside": true when b is a ring with its teeth inside}``. Checked with a goal (``goal_id``) on a make Kiln's servers answer; then the stage on this computer plays it too. Elsewhere the reply carries no ``motion``. | |
| goal_id | No | The saved goal's id from ``design_session``, so this make is recorded against the goal and checked against it. Empty when there is no goal. Default: "". | |
| timeout | No | Maximum compilation time in seconds (default 300). Default: 300. | |
| fastener | No | The fastener the user named, e.g. ``"M4"`` — pass only if they actually said one. Kiln does NOT read your OpenSCAD looking for screw holes; guessing intent out of geometry would be wrong often. No argument, no advisory. Default: "". | |
| scad_code | No | Valid OpenSCAD source code (provide this OR scad_path). Default: "". | |
| scad_path | No | Path to a .scad file (provide this OR scad_code). Default: "". |