Skip to content

Scripting API

Bake and export

from ArtisanPlugin.Scripting import ReliefApi as relief

The stack is only a recipe until it is evaluated. Two ways out: a mesh in the document, ready to be cast or joined to a shank, or a greyscale height map for a milling machine. Both recompute the saved project at full resolution — the preview resolution cap the panel uses to stay interactive is never applied headless, so expect the call to take real time at 1024 nodes and above.

Both require a saved relief project. Without one they throw This document has no relief project; create one with SetupProject/Add* or the ArtisanRelief command., and with an empty stack, The relief project has no operations; add at least one.

Bake

mesh_id = relief.Bake()

Takes no parameters. It recomputes the project and adds the result to the document as a plain Rhino mesh — an open relief surface when the project’s OutputType is "Mesh", a closed solid capped CapDistance millimetres below the workbench plane when it is "Thickness". This is the panel’s Accept, headless. The returned Guid is a genuine document object id, unlike the operation ids the Add* calls return.

The project is not consumed. It stays in the document exactly as it was, still editable and still bakeable: change a height, re-bake, and you get a second mesh — the first one is not replaced or deleted. Nor is the mesh linked back to the project; it is an ordinary mesh from that point on, and survives ClearProject(). If you are iterating, delete the previous mesh yourself.

The call opens its own undo record named "Relief", which is a no-op inside a scripting Transaction — wrap it in one when the bake is part of a longer edit so the whole thing undoes in one step. The views are redrawn on success.

Errors, all raised before or instead of adding anything to the document:

MessageCause
These relief operations could not be computed (missing curves, objects or files): <names>.An enabled operation references a deleted curve or object, a curve that is no longer closed, or a missing image/texture file. The kernel would silently skip it; headless that would bake a quietly wrong relief, so it is surfaced instead. Disable the operation or repair the reference — Operations() flags them as MissingReferences
Relief computation failed with the given parameters (…).The height field could not be evaluated
Relief meshing failed (…).The field was computed but the mesh could not be built from it
The relief has nothing to build; enable at least one operation.Every operation in the stack is disabled
Rhino rejected the relief mesh.The mesh was built but the document refused it

Export heightmap

relief.ExportHeightmap(filePath)
ParameterDefaultMeaning
filePathPath of the TIFF to write; it should end in .tif or .tiff

Returns nothing. It recomputes the project the same way Bake does and writes the height field straight to disk as a 16-bit greyscale TIFF, black at the lowest point and white at the highest — the depth CNC and CAM pipelines expect, and the reason a relief exported this way keeps far more Z detail than an 8-bit PNG could carry. Nothing is added to the document and the project is left untouched.

The path is normalised through the full path of the current process working directory before the folder is checked, so a relative path is resolved rather than rejected — but the folder must already exist: a missing one throws Folder not found: <directory>, with the absolute path it resolved to. Pass an absolute path when you want certainty about where the file lands. A blank path throws Pass the path of the TIFF file to write. The extension is not enforced; the file is written as TIFF whatever you name it. An existing file at that path is overwritten.

Beyond the shared errors above, The relief project has nothing to export. means the recompute produced no height field at all.

from ArtisanPlugin.Scripting import ReliefApi as relief, Transaction

with Transaction.Begin("Signet relief"):
    mesh_id = relief.Bake()

relief.ExportHeightmap(r"C:\out\signet.tif")   # writes a file, changes nothing