Scripting API
Assets
from ArtisanPlugin.Scripting import AssetsApi as assets
AssetsApi gives scripts access to your profile library, the curves the parametric tools build from. Scripts can list assets, reference them by name or id, draw one as a curve to preview it, save a curve of the document as a new asset, and organize the library.
An asset is a half profile: it is mirrored across its vertical axis, and a RING_SIDE_CURVE stays open. A RING_PROFILE, a SIGNET_TOP_PROFILE, a CLOSED_PROFILE or a CHARM_PROFILE can have a right half of its own instead of the mirrored one (the Symmetric option of the editor, turned off). Such an asset reports IsSymmetric as false; everything else works the same, and ExportAsCurve draws its real outline.
| Method | Returns |
|---|---|
Types() | Valid asset types: RING_PROFILE, EXTERNAL_RING_PROFILE, RING_SIDE_CURVE, SIGNET_TOP_PROFILE, BEZEL_PROFILE, CHANNEL_PROFILE, CHARM_PROFILE, PEGHEAD_PROFILE, … |
List(type = None) | Assets in the library, optionally filtered by type. Each has Id, Name, Type, Semantic, IsDefault, PointCount (the control points of the half profile, which hint at its complexity) and IsSymmetric (false when the profile has its own right half) |
GetDefault(type) | The default asset for a type: the one every Create uses when no profile is given |
ExportAsCurve(type, name, width = 0, height = 0, plane = None) | Adds the profile to the document as a curve and returns its id. See Previewing a profile |
CreateFromCurve(type, name, curveId, symmetric = False) | Saves a planar curve of the document as a new user asset and returns it. See Creating an asset from a curve |
Rename / Duplicate / SetDefault / Delete | Library management. See Organizing the library |
Referencing a profile
Wherever a method takes a profile parameter — a creation method like ClassicApi.Create, or a handle setter like TopProfile.SetProfile — you pass the asset’s name. It is matched case-insensitively within its type (and against the asset’s Semantic description, so libraries renamed on migration keep resolving). Omitting it falls back to the type’s default, and an unknown name fails with the list of available ones.
When two assets share a name, pick one by id with "id:<n>" (the Id that List returns), for example profile = "id:42". This works in every profile argument and every SetProfile, and in the MCP tools’ *profile arguments too. An id from another asset type is rejected, and the error says which type the slot takes.
from ArtisanPlugin.Scripting import AssetsApi as assets, ClassicApi as classic, Transaction
for a in assets.List("RING_PROFILE"):
print(a.Name, "-", a.Semantic)
print("default:", assets.GetDefault("RING_PROFILE").Name)
with Transaction.Begin("Ring on a knife-edge profile"):
classic.Create(width = 2.4, profile = "Knife Edge")
Which type does a slot take?
Each profile slot accepts one asset type. The ones the API exposes today:
| Slot | Asset type |
|---|---|
Shank profiles — ClassicApi.Create, IClassic.TopProfile/MidProfile/BottomProfile, ICathedral.Shank, IEternity.Shank.Upper/Lower, IBypass/IAdvancedCathedral stations, IContourBand, IWeddingRing.Profile | RING_PROFILE |
Signet face — SignetRingApi.Create, ISignetFace.SetProfile | SIGNET_TOP_PROFILE |
IClassic.ExternalProfile | EXTERNAL_RING_PROFILE |
IAdvancedSignetRing.SetLateralProfile | RING_SIDE_CURVE |
| Bezels | BEZEL_PROFILE |
| Channels and halos | CHANNEL_PROFILE |
| Pegheads | PEGHEAD_PROFILE |
| Charms | CHARM_PROFILE |
Previewing a profile
curveId = assets.ExportAsCurve("RING_PROFILE", "Knife Edge", width = 4, height = 2)
ExportAsCurve adds the asset to the document as a curve, so you can see the exact shape before building with it. You get the shape the tools actually build from: mirrored and closed, or open for RING_SIDE_CURVE.
- Size:
width×heightmm, where0means 5 × 3 like the Assets panel’s insert. A side curve keeps its aspect ratio and only followsheight. - Position: centred on
plane, which defaults to the active construction plane. - Library: unchanged. Delete the curve when you are done looking.
Creating an asset from a curve
from ArtisanPlugin.Scripting import AssetsApi as assets, ClassicApi as classic, Transaction
asset = assets.CreateFromCurve("RING_PROFILE", "My comfort fit", curveId)
print(asset.Name, asset.PointCount, asset.IsSymmetric)
with Transaction.Begin("Ring on my profile"):
classic.Create(width = 2.4, profile = asset.Name)
CreateFromCurve saves a planar curve of the document as a new user asset of type. It is the same conversion as Import curve in the Assets editor, so a script and the editor give the same profile for the same curve. The curve stays in the document, and the asset is saved to disk immediately.
- Name: must be free within the type.
- Which way is up: +Y for a curve drawn on the World XY plane, +Z for one drawn on a front or side plane. A curve on any other plane is read in its own plane.
- Size: only the shape counts. Each tool scales a profile to its own width and height.
- Open curve: it is the left half of the profile and is mirrored.
- Closed curve: it is cut along its vertical middle line. When its two sides differ and the type takes a right half of its own (
CLOSED_PROFILE,CHARM_PROFILE,SIGNET_TOP_PROFILE), both are kept and the asset reportsIsSymmetricas false. Otherwise the left side is mirrored. Passsymmetric = Trueto force the mirror. - Corners: kinks in the curve become sharp points of the profile.
A curve that is not planar, or that does not produce a valid profile of that type, is rejected with a message that says why. Look at the result with ExportAsCurve before you build with it.
Organizing the library
Each method picks the asset by type and name, where name can also be "id:<n>". Names stay unique within a type, and changes are saved to disk immediately.
| Method | Does |
|---|---|
Rename(type, name, newName) | Renames a user asset |
Duplicate(type, name, newName = None) | Copies any asset, standard ones included, as a new user asset. An empty newName gives "<name> (Copy)". This is how you get an editable copy of a factory profile |
SetDefault(type, name) | Makes it the default of its type, so every Create uses it when no profile is given |
Delete(type, name) | Deletes a user asset permanently. Objects already built from it keep their embedded copy |
Standard (factory) assets cannot be renamed or deleted, because tool defaults and scripts refer to them by name. Duplicate one instead.
from ArtisanPlugin.Scripting import AssetsApi as assets
copy = assets.Duplicate("RING_PROFILE", "Knife Edge", "Knife Edge - soft")
assets.SetDefault("RING_PROFILE", copy.Name)
From the MCP
AI assistants have the same features through MCP:
list_assetsbrowses the library.export_asset_curvedraws a profile as a curve.create_asset_from_curvesaves a curve of the document as a new asset.manage_assetsrenames, duplicates, sets the default and deletes.
See the tool reference. In the Python package, this page corresponds to ra.assets.