Skip to content

.NET API

FileApi

File-menu utilities that are not the plain open/save lifecycle (that one lives in DocumentApi): standardizing an imported document, moving the user’s element library between machines, and the template.

from ArtisanPlugin.Scripting import FileApi

See also the Python package, ra.files.

Methods

Method
ExportElementsExports 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.
ImportElementsImports 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.
SaveAsTemplateSaves the active document as the Artisan template (the ArtisanSaveAsTemplate tool, headless): Rhino’s SaveAsTemplate to “/Templates/template.3dm”, the file ArtisanNew starts from.
StandardizeStandardizes 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.

ExportElements

ElementsExport FileApi.ExportElements(string type, string path)

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 ElementsApi.Types() (“Bezel”, “Basket”, “Halo”, “Peghead”…); the store’s own names (“ADVANCED_BASKET”) are also accepted. ‘.json’ is appended when missing; the folder is created.

ParameterTypeDefault
typestringrequired
pathstringrequired

Returns ElementsExport.

ImportElements

ElementsImport FileApi.ImportElements(string path)

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.

ParameterTypeDefault
pathstringrequired

Returns ElementsImport.

SaveAsTemplate

string FileApi.SaveAsTemplate(string path = null)

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.

ParameterTypeDefault
pathstringnull

Returns string.

Standardize

StandardizeResult FileApi.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. Long on heavy documents. Returns counts of what was cleaned.

Returns StandardizeResult.