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, element = None,
thicknessBottom = 0, prongRotation = 0,
seat = None, seatAngle = 0,
galleryRail = None, galleryPosition = 0,
galleryHeight = 0, galleryWidth = 0) # -> 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: 4, or the shape’s own count when it has no 4 (a pear, a trillion or a triangle get 3). -4 is 4 prongs turned 45 degrees. Each shape has its own counts — see Prong counts |
height | 5 | Total head height, mm. Must be greater than overGirdleHeight |
thickness | 1 | Prong thickness, mm — at the top, when the prongs taper |
thicknessBottom | 0 | Prong thickness at the bottom of the head, mm, to taper the prongs. 0 = the same as thickness |
prongRotation | 0 | Degrees the prongs are turned around the stone, from the positions the shape gives them (counter-clockwise seen from above) |
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") |
element | None | A saved Peghead element (ElementsApi.List("Peghead")) to start from; explicit arguments override it |
seat | None | True cuts the seat of the stone into the prongs: what the stone occupies is taken out of them. It shows where the stone sits inside the prongs, so use it with gemInside above 0 |
seatAngle | 41 | Angle of the seat below the girdle, 10 to 80 degrees from the girdle plane |
galleryRail | None | True adds a rail around the head, under the stone, that ties the prongs together |
galleryPosition | automatic | How far below the girdle the middle of the rail is, mm. 0 = a little above the middle of the body |
galleryHeight | 0.8 | Height of the rail, mm |
galleryWidth | 0.8 | Width of the rail, mm, measured in from the outside of the head |
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.
It works on every stone shape, and the result is always a valid closed polysurface: a combination that would not build one is refused, with the reason, and nothing is left in the document.
Prong counts
Each shape has prong positions for some counts only — the ones the panel offers. Another count throws a ScriptingValidationException that names the valid ones. The same table holds for every setting that places its prongs on those positions: basket, tulip, the centre prongs of a halo and of a cluster, the prong axes and the tulips of a trilogy.
| Shape | Counts |
|---|---|
| Round | 3, 4, -4, 6 |
| Oval | 3, 4, 6 |
| Heart | 3, 4, 5 |
| Pear | 3, 5 |
| Marquise | 4, 6 |
| Princess, cushion, emerald, radiant, asscher, baguette, tapered baguette, coffin | 4 |
| Trillion, triangle, calf | 3 |
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; one the shape does not have is rejected with the valid list |
SetHeight(mm) | Total head height - must be greater than the height over the girdle |
SetThickness(mm) | Prong thickness (at the top) - must be > 0 |
SetThicknessBottom(mm) | Prong thickness at the bottom, to taper the prongs; 0 removes the taper |
SetProngRotation(degrees) | Turns the prongs around the stone |
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 |
SetSeat(bool), SetSeatAngle(degrees) | The seat cut into the prongs, and its angle below the girdle (10 to 80) |
SetGalleryRail(bool) | Adds or removes the gallery rail |
SetGalleryPosition(mm), SetGalleryHeight(mm), SetGalleryWidth(mm) | Where the rail is below the girdle (0 = automatic) and its section |
An edit that cannot be built, or that would build an invalid polysurface, is undone: the peghead stays as it was and the setter throws.
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("Tapered prongs with a seat and a rail"):
p.SetThickness(0.9)
p.SetThicknessBottom(0.6)
p.SetGemInside(0.2)
p.SetSeat(True)
p.SetGalleryRail(True)
Mutations belong inside a Transaction so the whole edit lands as one undo step.
Queries
All(), Find(id), Count(), Selected(), ByLayer(name), ForGem(gemId).