Skip to content

Scripting API

The project stack

from ArtisanPlugin.Scripting import ReliefApi as relief

A relief project is the recipe a signet face, a textured band or an engraved plaque is built from: a rectangular workbench plane, a sampling grid over it, and an ordered stack of operations that each raise or lower the height field. The project lives in the document (it is written into the .3dm), which is the same project the ArtisanRelief panel edits — so a script can rough out four layers and hand them to the bench for refinement, or pick up what the panel left behind.

If you only need a single-operation relief meshed in one call, the one-shot creators — Create from image, Create from curves and Create from geometry — work on a transient project and leave the document’s saved one untouched.

The stack model

The project holds a list of operations. They are evaluated in order, index 0 first, each one writing into the height field the operations below it have already built. Every operation carries a combine mode saying how its own layer merges into that accumulated height, and an Enabled flag; disabled operations are skipped. Nothing is computed while you build the stack — the field is only evaluated when you bake or export.

Because each mode applies over the running result, order changes the outcome. A Multiply texture placed above a domed profile modulates that dome; the same texture placed below it multiplies a flat zero field and disappears.

Combine modes

Combine modes are plain strings — case-insensitive, no kernel import needed; omitting combine means "Add":

ModeEffect on the accumulated heightTypical use
Addheights += layer (the default)Stack a motif onto a base
Subtractheights -= layerEngrave a shape out of what is below
ZMaxUnion Highest: keeps whichever is tallerMerge two domes without their overlap doubling
ZMinUnion Lowest: keeps whichever is lowerClip the relief down to a lower shape
AbsoluteNo merge — the layer’s values are placed as-is inside its own mask, substituting what is underneathPunch a flat plateau or an exact stamped depth
Multiplyheights *= layer, the layer acting as a scale factorModulate an existing relief with a texture

Reading the project

info = relief.GetProject()
ops  = relief.Operations()
names = relief.ProfileNames()

All three are read-only and take no arguments. None of them throws when the document has no project.

GetProject() returns a ReliefProjectInfo:

FieldTypeMeaning
ExistsboolFalse — with every other field left at zero — when the document has no saved relief project
WorldWidthdoubleWorkbench width in millimetres
WorldHeightdoubleWorkbench height in millimetres
ResolutionintGrid nodes along the larger side
OutputTypestr"Mesh" (open relief) or "Thickness" (closed solid)
CapDistancedoubleSolid thickness below the base plane, in millimetres
DeleteBaseboolTrue when grid cells no operation touched are trimmed away
OperationCountintNumber of operations in the stack, enabled or not

Operations() returns the stack in apply order as a read-only list of ReliefOperationInfo — an empty list when there is no project:

FieldTypeMeaning
IdGuidThe operation id, the handle every editing call takes. See Editing the stack
IndexintPosition in the stack; 0 is applied first
Typestr"profile", "extrude", "image", "texture", "geometry", "sculpt" or "smooth"
NamestrThe label on the panel’s card
EnabledboolFalse operations are skipped when the field is evaluated
CombineModestrThe mode name, e.g. "Multiply"
MissingReferencesboolTrue when a referenced curve or object no longer resolves, is no longer closed, or a referenced image/texture file is gone

ProfileNames() returns the names the profile parameter of a profile operation accepts: the four built-in presets — Round, Smooth, Chamfer, Plateau — followed by the profiles saved in the user’s own profile library. Matching is case-insensitive; an unrecognised name throws Unknown relief profile '...'. Use one of: ..., listing the whole set.

The "sculpt" and "smooth" types are created with the panel’s brushes or with AddSculpt / AddSmooth, and can be toggled, reordered and removed like any other operation.

Usage

relief.SetupProject(worldWidth = 0, worldHeight = 0, resolution = 0,
                    workbench = None, solid = True, capDistance = 0,
                    deleteBase = False)
ParameterDefaultMeaning
worldWidth050Workbench width in millimetres
worldHeight050Workbench height in millimetres
resolution0512Grid nodes along the larger side; must be 0 or between 64 and 4096
workbenchNone → world XYThe Plane the relief sits on; the grid is centred on its origin. None leaves the project’s current plane untouched when one already exists
solidTrueTrue bakes a closed solid (OutputType "Thickness"), False an open mesh
capDistance01.0Solid thickness below the base plane, in millimetres
deleteBaseFalseTrue trims away grid cells no operation touched

Returns nothing. It creates the document’s relief project if there is none, or reconfigures the settings of the existing one keeping its operation stack, and saves the result back into the document. Mutations belong inside a Transaction for one-step undo.

0 here means the panel default, not leave what is saved. Calling relief.SetupProject() on a project already set to 20 × 20 at 1024 nodes resets it to 50 × 50 at 512 — pass the values you want to keep. workbench is the one exception: None genuinely leaves the saved plane alone.

Validation throws ArgumentException before anything is written: Workbench size cannot be negative., Resolution must be between 64 and 4096 (0 = default 512). and capDistance cannot be negative.

The natural order works: call SetupProject first to configure the workbench, then add operations — an empty project persists its settings, and every later Add* builds on them instead of auto-fitting its own. (Only when there is no project at all does the first Add* auto-fit one to its inputs.) ClearProject deletes the saved project entirely.

Building a stack

from ArtisanPlugin.Scripting import ReliefApi as relief, Transaction

with Transaction.Begin("Signet relief"):
    dome  = relief.AddProfile([crest_curve], height = 1.2, profile = "Smooth")
    grain = relief.AddTexture("KNURL01.jpg", height = 0.15, tilesU = 8, tilesV = 8,
                              combine = "Multiply", name = "Grain")

    # now that the stack is non-empty, the workbench sticks
    relief.SetupProject(worldWidth = 20, worldHeight = 20, resolution = 1024,
                        solid = True, capDistance = 1.5)

    mesh_id = relief.Bake()

The five Add* calls are documented in Operations; each returns the operation id you feed to Editing the stack.