Skip to content

Scripting API

Chain

from ArtisanPlugin.Scripting import ChainApi

A chain is a run of identical links threaded one after another along a path - the neckchain, the bracelet, the run of charms down a drop earring. Artisan divides the curve into equal segments, builds a perpendicular frame at each division point, and drops a copy of your link geometry onto every frame, so each copy sits square to the curve as it turns.

Create

ids = ChainApi.Create(objectIds, curveId, copies = 0)      # -> [ids]
ParameterDefaultMeaning
objectIdscurrent selectionThe link objects to repeat. Empty or None falls back to the objects currently selected in the document
curveIdrequiredThe curve to lay the chain along; must resolve to a curve
copies10Number of divisions of the curve

copies follows the house 0-keeps-default convention: 0 means “use the tool’s default of 10, or my saved chain defaults”. Chain has no -1 sentinel.

The count is a division count, not a placement count. The curve is divided by copies segments with the ends included, so an open curve receives copies + 1 placements - copies = 10 gives eleven copies of each source object, one at each end. The advanced options of the panel are not exposed here and keep whatever your saved defaults hold: the alternating odd/even rotations about X, Y and Z that give a chain its twist, the include-ends flag and curve adaptation.

Create returns the ids of the copies it made - one id per source object per division point, so a two-object selection along a ten-division curve returns twenty-two ids. The source objects are kept. They are not consumed, moved or hidden; the copies are added alongside them.

The copies are made with Rhino’s transform-with-history, so each one inherits the attributes of the object it came from - its layer, its colour, its material - and stays linked to the source through Rhino’s history record. This is not the metal-layer routing the other accessories perform: the copies land where their sources lived, and it is the source objects themselves that Artisan moves onto the metal layer as it works. Chain also does not create an editable smart object; the results are ordinary Rhino copies, not a component you can reopen in the panel.

Placement is measured from the active view’s construction plane, positioned at the centre of the combined bounding box of all the source objects. Move that centre and you move the chain relative to its curve.

This is a licensed mutation and needs an active document. It raises “Object <id> is not a curve.” when curveId names something else, “At least one object to repeat is required.” when neither objectIds nor the selection yields anything, “INVALID_COPIES” when the resolved copy count is 1 or less, and “Chain computation failed on that curve.” when no frames can be built along it. Wrap the call in a Transaction to get one-step undo over the whole run.