Scripting API
Charm
from ArtisanPlugin.Scripting import CharmApi
A charm is the small flat pendant that hangs from a bracelet or a chain - a heart, a star, a clover. Artisan takes the outline from a charm profile asset and gives it its width, height and metal thickness.
Create
id = CharmApi.Create(plane = ..., width = 8, height = 6, thickness = 2.8,
profile = None) # -> id
| Parameter | Default | Meaning |
|---|---|---|
plane | active CPlane | Placement plane; omitted or invalid falls back to the active view’s construction plane, then to Plane.WorldXY |
width | 8 | Overall width, mm |
height | 6 | Overall height, mm |
thickness | 2.8 | Metal thickness, mm |
profile | saved/default | A CHARM_PROFILE asset name |
The three numbers follow the 0-keeps-default convention: 0 means “use the tool’s default, or my saved defaults”. This facade has no -1 sentinel.
Create returns the single Guid of the charm - a parametric Charm custom object, added to the metal layer with the document’s metal material, exactly like the panel’s Accept.
Defaults resolve as in the tool: the charm-profile asset is resolved first (by name when profile is given), then your saved charm defaults replace the whole model - but only when no explicit profile was passed. Asking for a profile therefore also discards your saved width, height and thickness, so pass them alongside it.
This is a licensed mutation and needs an active document. If the charm cannot be built it raises “Charm computation failed with the given parameters.” Wrap the call in a Transaction for one-step undo.