Skip to content

Scripting API

Micro setting

from ArtisanPlugin.Scripting import MicroSettingApi as micro

Micro setting is the metalwork that makes a run of small stones sit properly: a seat cut under each stone, a V-groove between them, optionally a channel wall along the run and prongs raised over the row. It does not create the gems - you place those first, then this tool builds the infrastructure around them, exactly as the ArtisanMicroSetting panel does.

This is a multi-gem object driven by a run of existing stones, so MotherGemId is the first stone of the run; the whole run is kept on the group as motherGems.

Create

ids = micro.Create(gemIds = None, cutters = None, vCutters = None,
                   channel = None, rowProngs = None, settings = None)   # -> object ids
ParameterDefaultMeaning
gemIdsNoneThe run of gems to set, in row order; None or empty uses the current selection. At least one is required, and every id must be a gem
cuttersNone (tool default on)Seat cutter under each stone
vCuttersNone (tool default on)V-cutters between the stones
channelNone (tool default off)Channel wall along the run
rowProngsNone (tool default off)Prongs raised over the row
settingsNoneEvery other parameter, as a JSON object by section (below)

The four flags are nullable on purpose: pass True or False to force an element on or off, or leave them None to keep the tool’s behaviour - or the user’s saved micro-setting defaults where they exist. A flag wins over "enabled" in settings.

Create returns the ids of every object baked - cutters, V-cutters, the channel and the row prongs - each kind in its own Rhino sub-group, with the whole lot collected under one master MicroSetting group carrying the parameters and the parent gems.

Create throws if no gems are given or selected, if any id is not a gem, if a value in settings is not valid, if the computation fails with the given parameters, or if nothing at all was produced. Nothing is added to the document in any of those cases.

import json
from ArtisanPlugin.Scripting import MicroSettingApi as micro, Transaction

with Transaction.Begin("Micro set the row"):
    ids = micro.Create(rowGemIds, rowProngs = True, settings = json.dumps({
        "cutters": {"start_width": 0.8, "end_width": 0.8, "shape": "V_SHAPE"},
        "v_cutters": {"width_by_percentage": True, "width_percentage": 40},
        "row_prongs": {"diameter": 0.5, "end_prongs": "One"},
    }))

Mutations belong inside a Transaction so the whole build lands as one undo step.

Settings

settings is a JSON object with up to four sections. Only the keys you give change; the rest keep the tool defaults. Lengths are millimetres. A key that does not exist, or a value out of range, throws an error that names the section, the key and what it takes.

SectionKeys
cuttersenabled, keep, start_width, end_width, start_height, end_height, length, over_girdle, over_girdle_middle, shape, shape_factor, width_by_percentage, width_percentage
v_cuttersenabled, keep, start_width, end_width, start_height, end_height, length, over_girdle, over_girdle_middle, width_by_percentage, width_percentage
channelenabled, keep, precise, close, flat_ends, flip_start, flip_end, flip_cap_start, flip_cap_end, start_width, end_width, start_height, end_height, start_over_girdle, end_over_girdle, start_extension, end_extension, start_bend, end_bend, extend_factor, shape, shape_factor, width_by_percentage, width_percentage
row_prongsenabled, diameter, height_over_girdle, height_under_girdle, x_center_prongs, y_center_prongs, allow_collisions, close, smart_adapt, diameter_by_percentage, inside_percentage, position_by_percentage, side_percentage, end_prongs
  • Widths, heights, length and diameter must be greater than 0. The over_girdle, extension and bend values are signed.
  • cutters.shape: U_SHAPE, V_SHAPE, SQUARE_SHAPE, TRAPEZOIDAL_SHAPE, FRENCH_SETTING_SHAPE.
  • channel.shape: UShape, VShape, SquareShape, TrapezoidalShape, ChannelShape.
  • row_prongs.end_prongs: Two, One, None - the prongs closing the first and the last stone of an open row.
  • row_prongs.inside_percentage is above 0 and below 50; side_percentage is 0 or more.

Graduated rows

On a row of stones of different sizes, a fixed width fits one stone and is wrong for the rest. width_by_percentage sizes each piece from its own stone instead:

SectionWith width_by_percentage onDefault width_percentage
cuttersEach cutter is that percentage of its stone50
v_cuttersEach V-cutter is that percentage of the two stones it sits between, averaged40
channelThe channel has one section per stone, that percentage of it wide100

The row prongs have their own pair: diameter_by_percentage with inside_percentage, and position_by_percentage with side_percentage.

Edit

All() and Find(id) return the IMicroSetting handle. It has one section per element - Cutters, VCutters, Channel, RowProngs - and every value of a section can be read and set:

setting = micro.All()[0]
print(setting.Cutters.StartWidth, setting.VCutters.WidthByPercentage)

setting.Cutters.SetStartWidth(0.9)           # one rebuild
setting.SetParameters(json.dumps({           # several values, one rebuild
    "cutters": {"end_width": 0.9},
    "channel": {"enabled": True},
}))

An edit rebuilds the micro-setting on the same stones. The handle and its Id stay valid; the cutters, the channel and the prongs are new objects with new ids. A value that cannot be built throws and leaves the micro-setting as it was.

On top of the sections the handle carries the shared Id, ObjectType ("MicroSetting"), MotherGemId, LayerName, Position, plus Move() and Delete().

Queries

All(), Find(id), Count(), Selected(), ByLayer(name).

These resolve the micro-settings of the active document and return IMicroSetting handles for them.