Scripting API
Peghead
from ArtisanPlugin.Scripting import PegheadApi as peghead
A peghead is the prong head that grips a stone from above and carries it on a peg - the small claw crown you solder or set into a shank, a pendant or an earring. The tool sweeps a PEGHEAD_PROFILE section along each prong, seats the claws on the girdle and closes the head under the pavilion, exactly as the ArtisanPeghead panel does.
It is built around a mother gem and stays its parametric child: gemId must already be a gem in the active document.
Create
p = peghead.Create(gemId, prongs = 4, height = 5, thickness = 1,
girdleWidth = 0.8, overGirdleHeight = 1,
gemInside = 0, profile = None) # -> IPeghead
| Parameter | Default | Meaning |
|---|---|---|
gemId | - | The mother gem it holds - throws if the object is not a gem |
prongs | 4 | Number of prongs; 0 keeps the default. Negative counts give the rotated variant (-4 = 4 prongs turned 45 degrees) |
height | 5 | Total head height, mm |
thickness | 1 | Prong thickness, mm |
girdleWidth | 0.8 | How far the claw bites over the girdle, mm |
overGirdleHeight | 1 | How high the claw rises above the girdle, mm |
gemInside | 0 | How deep the stone sits inside the head, mm - accepts negatives |
profile | None | PEGHEAD_PROFILE asset by name - see AssetsApi.List("PEGHEAD_PROFILE") |
Millimetres throughout, and 0 keeps the tool default - or the user’s saved defaults for the peghead, when they have stored any. Passing an explicit profile skips those saved defaults, since they replace the whole model, profile included.
The baked head goes onto the metal layer and gets the current metal material, like the tool’s Accept. Create throws if gemId is not a gem or if the geometry fails to compute.
Edit
Create, Find and All return an IPeghead handle. Each setter regenerates the object in place, keeping its Guid and undo intact:
| Setter | What it changes |
|---|---|
SetProngs(n) | Prong count; 0 is rejected, negatives give the rotated variant |
SetHeight(mm) | Total head height - must be > 0 |
SetThickness(mm) | Prong thickness - must be > 0 |
SetGirdleWidth(mm) | Bite over the girdle - must be > 0 |
SetOverGirdleHeight(mm) | Claw height above the girdle - must be > 0 |
SetGemInside(mm) | Seat depth of the stone; accepts any value, including negatives |
The handle also reports GemShape, GemMaterial and GemCaratWeight for the mother stone, plus the shared Id, MotherGemId, LayerName, Position, Move() and Delete().
from ArtisanPlugin.Scripting import PegheadApi as peghead, Transaction
p = peghead.Selected()[0]
with Transaction.Begin("Six rotated prongs"):
p.SetProngs(-6)
p.SetThickness(0.9)
Mutations belong inside a Transaction so the whole edit lands as one undo step.
Queries
All(), Find(id), Count(), Selected(), ByLayer(name), ForGem(gemId).