Skip to content

.NET API

ElementsApi

The user’s saved ELEMENTS: the named presets the panels store from their “save as element” button (a bezel called “Chunky”, a basket called “Client A”…). They were invisible to scripting — a whole category of the user’s own work that no script could see or reuse. Queries and the parameters themselves, so every creator can build from a preset (element=…) and handles can apply one (SetElement), plus SaveFromObject to store an object as a new element, and library management: rename, duplicate, favorite, delete (permanent), export and import bundles.

from ArtisanPlugin.Scripting import ElementsApi

See also the guide, API Reference › Elements, and the Python package, ra.elements.

Methods

Method
CountNumber of objects of this kind in the active document.
DeletePERMANENTLY deletes a saved element (as the panels’ delete does; there is no trash).
DuplicateCopies a saved element as newName (empty = ” (Copy)”), sharing its preview image.
ExportBundleExports a saved element as a bundle file (its parameters and preview) to filePath (.zip), to share it or move it to another machine.
FindFinds one saved element by name within a type (case-insensitive).
GetParametersJsonThe stored parameters of a saved element, as JSON.
ImportBundleImports an element bundle exported by ExportBundle (or the panels) into the library.
ListThe saved elements of one type, newest library order.
RenameRenames a saved element; the new name must be free within its type.
SaveFromObjectSaves an existing parametric object’s parameters as a new element (the panels’ “save as element”): objectId is the object, or any member of a parametric group (bail, basket, halo…); name must be new within its type.
SetFavoriteMarks or unmarks a saved element as favorite (favorites list first).
TypesThe element types the library can hold, as the names List() takes.

Count

int ElementsApi.Count(string type)

Number of objects of this kind in the active document.

ParameterTypeDefault
typestringrequired

Returns int.

Delete

bool ElementsApi.Delete(string type, string name)

PERMANENTLY deletes a saved element (as the panels’ delete does; there is no trash). Objects built from it are not affected. Returns true when it is gone.

ParameterTypeDefault
typestringrequired
namestringrequired

Returns bool.

Duplicate

ElementInfo ElementsApi.Duplicate(string type, string name, string newName = null)

Copies a saved element as newName (empty = ” (Copy)”), sharing its preview image.

ParameterTypeDefault
typestringrequired
namestringrequired
newNamestringnull

Returns ElementInfo.

ExportBundle

string ElementsApi.ExportBundle(string type, string name, string filePath)

Exports a saved element as a bundle file (its parameters and preview) to filePath (.zip), to share it or move it to another machine. Returns the written path.

ParameterTypeDefault
typestringrequired
namestringrequired
filePathstringrequired

Returns string.

Find

ElementInfo ElementsApi.Find(string type, string name)

Finds one saved element by name within a type (case-insensitive). Throws listing the available names when it does not match, so a script or an agent can correct itself.

ParameterTypeDefault
typestringrequired
namestringrequired

Returns ElementInfo.

GetParametersJson

string ElementsApi.GetParametersJson(string type, string name)

The stored parameters of a saved element, as JSON. Mostly useful to inspect a preset; the facades take the element by name instead.

ParameterTypeDefault
typestringrequired
namestringrequired

Returns string.

ImportBundle

ElementInfo ElementsApi.ImportBundle(string filePath)

Imports an element bundle exported by ExportBundle (or the panels) into the library. Returns the imported element.

ParameterTypeDefault
filePathstringrequired

Returns ElementInfo.

List

IReadOnlyList<ElementInfo> ElementsApi.List(string type)

The saved elements of one type, newest library order. type is one of Types() — “Bezel”, “Basket”, “Halo”, “Peghead”…

ParameterTypeDefault
typestringrequired

Returns IReadOnlyList<ElementInfo>.

Rename

ElementInfo ElementsApi.Rename(string type, string name, string newName)

Renames a saved element; the new name must be free within its type.

ParameterTypeDefault
typestringrequired
namestringrequired
newNamestringrequired

Returns ElementInfo.

SaveFromObject

ElementInfo ElementsApi.SaveFromObject(Guid objectId, string name)

Saves an existing parametric object’s parameters as a new element (the panels’ “save as element”): objectId is the object, or any member of a parametric group (bail, basket, halo…); name must be new within its type. No preview image. Returns the saved element.

ParameterTypeDefault
objectIdGuidrequired
namestringrequired

Returns ElementInfo.

SetFavorite

ElementInfo ElementsApi.SetFavorite(string type, string name, bool favorite = true)

Marks or unmarks a saved element as favorite (favorites list first).

ParameterTypeDefault
typestringrequired
namestringrequired
favoritebooltrue

Returns ElementInfo.

Types

IReadOnlyList<string> ElementsApi.Types()

The element types the library can hold, as the names List() takes.

Returns IReadOnlyList<string>.