Skip to content
AlphaToolBox3D is in early alpha: features are incomplete and things can break. Use it at your own risk and keep copies of your files. Report a problem
ToolBox3D

Docs · Python API

tb.ops.openscad

3 operations. Without targets=, an operation works on the current selection, like its button in the editor.

Check OpenSCAD Printability

tb.ops.openscad.check(
    *,
    source: str = ...,
    params: Any = ...,
    files: Any = ...,
    folder: str = ...,
) -> Result

Evaluate an OpenSCAD script without changing the scene and report its printability in OpenSCAD units (millimetres): triangle count, volume, surface area, bounding-box size, separate pieces and whether the mesh is watertight, plus echo() output and warnings. Bake with openscad.run to keep it.

  • Operation openscad.check
  • In Model
ArgumentTypeDefaultDescription
sourcestr—The OpenSCAD script (.scad text), at most 4 MB. include/use reach the bundled libraries (BOSL2 and others, e.g. include <BOSL2/std.scad>) and the 'files' given.
paramsAny—Customizer values by parameter name, e.g. {"width": 40, "hole": false}. Only the script's declared customizer parameters are accepted; others are refused with the list of declared names.
filesAny—Your own files the script may include, use or import, by path relative to the script's folder root: {"lib/peg.scad": "module peg() {...}", "part.stl": "data:model/stl;base64,..."}. Text as a string, binary files as a base64 data URL; at most 512 files and 64 MB. Paths leaving the folder are refused.
folderstr—The script's own folder inside 'files' (relative includes start there); the root by default.

OpenSCAD Parameters

tb.ops.openscad.parameters(*, source: str = ...) -> Result

The customizer parameters an OpenSCAD script declares, in source order: name, group, description, default value and control (number, slider, checkbox, text, dropdown, vector).

  • Operation openscad.parameters
  • In Model
ArgumentTypeDefaultDescription
sourcestr—The OpenSCAD script (.scad text), at most 4 MB. include/use reach the bundled libraries (BOSL2 and others, e.g. include <BOSL2/std.scad>) and the 'files' given.

Bake OpenSCAD

tb.ops.openscad.run(
    *,
    source: str = ...,
    params: Any = ...,
    files: Any = ...,
    folder: str = ...,
    unit: Literal["m", "cm", "mm", "inch", "foot"] = "mm",
    name: str = ...,
    replace: ObjectRef = ...,
    smooth_angle: float = 30.0,
) -> Result

Evaluate an OpenSCAD script and bake the result into the Model scene as a mesh object (one undo step). With 'replace', the earlier bake is updated in place. Returns the object, mesh, counts, echo() output and warnings; script errors name the line.

  • Operation openscad.run
  • In Model
ArgumentTypeDefaultDescription
sourcestr—The OpenSCAD script (.scad text), at most 4 MB. include/use reach the bundled libraries (BOSL2 and others, e.g. include <BOSL2/std.scad>) and the 'files' given.
paramsAny—Customizer values by parameter name, e.g. {"width": 40, "hole": false}. Only the script's declared customizer parameters are accepted; others are refused with the list of declared names.
filesAny—Your own files the script may include, use or import, by path relative to the script's folder root: {"lib/peg.scad": "module peg() {...}", "part.stl": "data:model/stl;base64,..."}. Text as a string, binary files as a base64 data URL; at most 512 files and 64 MB. Paths leaving the folder are refused.
folderstr—The script's own folder inside 'files' (relative includes start there); the root by default.
unitLiteral["m", "cm", "mm", "inch", "foot"]"mm"The length one OpenSCAD unit stands for; 3D-printing models are in millimetres. (m / cm / mm / inch / foot).
namestr—Object name, at most 64 characters (default OpenSCAD<n>).
replaceObjectRef—An earlier OpenSCAD object to re-bake in place: it keeps its name, transform and materials and gets the new mesh.
smooth_anglefloat30.0Edges sharper than this angle shade hard (flat faces and crisp edges), gentler ones smooth (round surfaces). (degrees; 0…180).