Scripting API
Milgrain
from ArtisanPlugin.Scripting import MilgrainApi
Milgrain is the row of minute beads a setter runs along an edge or a bezel rim to soften it and catch the light - traditionally raised with a knurling wheel. The tool does the same digitally: it takes a curve you have already drawn, spaces spheres of the given diameter along it, and overlaps them slightly so the run reads as one continuous beaded rope rather than a string of separate balls.
Create
id = MilgrainApi.Create(curveId, diameter = 0.8, overlapping = 0.1) # -> id
| Parameter | Default | Meaning |
|---|---|---|
curveId | required | The curve the beads run along |
diameter | 0 -> tool default 0.8 | Bead diameter, mm |
overlapping | 0 -> tool default 0.1 | How much consecutive beads overlap, mm |
Milgrain takes no plane: the curve is the path, and it decides where the beads go. curveId is resolved against the document and must be a curve; anything else - a solid, a surface, or an id that is not in the document at all - throws ArgumentException with the message “Object … is not a curve.” before any geometry work begins.
Both numeric parameters follow the house 0-keeps-default convention, and there is no -1 sentinel here: neither a zero bead diameter nor a zero overlap is meaningful. Defaults come from the Milgrain model the ArtisanMilgrain command uses, overwritten by the user’s saved milgrain defaults when they have any.
Create returns the single Guid of the baked milgrain object. There is no handle and no query methods on this facade. The object is a smart component that remembers the curve it was built on, and it lands on the metal layer with the document’s metal material, exactly as the panel’s Accept leaves it. The source curve itself is left alone.
Create throws InvalidOperationException with “Milgrain computation failed on that curve.” when the beads cannot be built - a curve far shorter than one bead, or an overlap large enough to swallow the spacing, are the usual causes - and it throws when the licence is not valid. Wrap the call in a Transaction if you want it to undo as a single step.