.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 | |
|---|---|
Count | Number of objects of this kind in the active document. |
Delete | PERMANENTLY deletes a saved element (as the panels’ delete does; there is no trash). |
Duplicate | Copies a saved element as newName (empty = ” |
ExportBundle | Exports a saved element as a bundle file (its parameters and preview) to filePath (.zip), to share it or move it to another machine. |
Find | Finds one saved element by name within a type (case-insensitive). |
GetParametersJson | The stored parameters of a saved element, as JSON. |
ImportBundle | Imports an element bundle exported by ExportBundle (or the panels) into the library. |
List | The saved elements of one type, newest library order. |
Rename | Renames a saved element; the new name must be free within its type. |
SaveFromObject | 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. |
SetFavorite | Marks or unmarks a saved element as favorite (favorites list first). |
Types | The 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.
| Parameter | Type | Default |
|---|---|---|
type | string | required |
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.
| Parameter | Type | Default |
|---|---|---|
type | string | required |
name | string | required |
Returns bool.
Duplicate
ElementInfo ElementsApi.Duplicate(string type, string name, string newName = null)
Copies a saved element as newName (empty = ”
| Parameter | Type | Default |
|---|---|---|
type | string | required |
name | string | required |
newName | string | null |
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.
| Parameter | Type | Default |
|---|---|---|
type | string | required |
name | string | required |
filePath | string | required |
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.
| Parameter | Type | Default |
|---|---|---|
type | string | required |
name | string | required |
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.
| Parameter | Type | Default |
|---|---|---|
type | string | required |
name | string | required |
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.
| Parameter | Type | Default |
|---|---|---|
filePath | string | required |
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”…
| Parameter | Type | Default |
|---|---|---|
type | string | required |
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.
| Parameter | Type | Default |
|---|---|---|
type | string | required |
name | string | required |
newName | string | required |
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.
| Parameter | Type | Default |
|---|---|---|
objectId | Guid | required |
name | string | required |
Returns ElementInfo.
SetFavorite
ElementInfo ElementsApi.SetFavorite(string type, string name, bool favorite = true)
Marks or unmarks a saved element as favorite (favorites list first).
| Parameter | Type | Default |
|---|---|---|
type | string | required |
name | string | required |
favorite | bool | true |
Returns ElementInfo.
Types
IReadOnlyList<string> ElementsApi.Types()
The element types the library can hold, as the names List() takes.
Returns IReadOnlyList<string>.