Skip to content

Python package

ra.files

File utilities: standardize, elements import/export, layer exports.

import rhinoartisan as ra

Wraps ArtisanPlugin.Scripting.FileApi.

Functions

Function
export_elements()Exports every saved element of one type to a JSON file (the ArtisanExportElementsByType tool, headless) — the way to carry the user’s presets (bezels, baskets, halos…) to another machine.
import_elements()Imports elements into the user’s library (the ArtisanImportElementsByFile tool, headless): either a single “.raelement” bundle (element + preview) or a “.json” array as written by ExportElements.
save_as_template()Saves the active document as the Artisan template (the ArtisanSaveAsTemplate tool, headless): Rhino’s SaveAsTemplate to “/Templates/template.3dm”, the file ArtisanNew starts from.
standardize()Standardizes a document that came from elsewhere (the ArtisanStandardize tool, headless), running the same sequence as the command: explode every block instance, recover the gems (ArtisanGemsRecover), move solids/meshes to the metal layers (ArtisanOrganizeObjectsByLayers), purge all render materials, re-apply the Artisan design materials, and estimate the ring size.

ra.files.export_elements()

ra.files.export_elements(type: str, path: str) -> ElementsExport

Exports every saved element of one type to a JSON file (the ArtisanExportElementsByType tool, headless) — the way to carry the user’s presets (bezels, baskets, halos…) to another machine. type is one of ra.elements.types() (“Bezel”, “Basket”, “Halo”, “Peghead”…); the store’s own names (“ADVANCED_BASKET”) are also accepted. ‘.json’ is appended when missing; the folder is created.

ParameterType
typestrrequired
pathstrrequired

ra.files.import_elements()

ra.files.import_elements(path: str) -> ElementsImport

Imports elements into the user’s library (the ArtisanImportElementsByFile tool, headless): either a single “.raelement” bundle (element + preview) or a “.json” array as written by ExportElements. Elements that already exist (same id) are skipped, like the tool; where the tool asks “add the new ones?” this just adds them. Returns what was imported.

ParameterType
pathstrrequired

ra.files.save_as_template()

ra.files.save_as_template(path=None) -> str

Saves the active document as the Artisan template (the ArtisanSaveAsTemplate tool, headless): Rhino’s SaveAsTemplate to “/Templates/template.3dm”, the file ArtisanNew starts from. path overrides the destination (‘.3dm’ appended, folder created). Returns the full path written.

ParameterType
pathstroptional — None = the tool default

ra.files.standardize()

ra.files.standardize() -> StandardizeResult

Standardizes a document that came from elsewhere (the ArtisanStandardize tool, headless), running the same sequence as the command: explode every block instance, recover the gems (ArtisanGemsRecover), move solids/meshes to the metal layers (ArtisanOrganizeObjectsByLayers), purge all render materials, re-apply the Artisan design materials, and estimate the ring size. Long on heavy documents. Returns counts of what was cleaned.