Skip to content

Scripting API

Voronoi

from ArtisanPlugin.Scripting import VoronoiApi

The irregular, cracked-mud cell pattern used for openwork pendants, pierced ring panels and cut-out earrings. The tool scatters points random seeds inside the bounding box of your outline, builds the Voronoi web from their Delaunay triangulation, trims every edge at the outline, then thickens and extrudes those edges into metal walls.

Create

ids = VoronoiApi.Create(curveId, points = 100, thickness = 0, height = 0,
                        bothSides = False)                                  # -> [ids]
ParameterDefaultMeaning
curveId-The existing outline the pattern fills - must be planar and closed
points100Seed points scattered in the outline’s bounding box
thickness0Wall thickness, mm - 0 gives bare centre lines and no solid
height0Wall height, mm - 0 gives flat outlines and no solid
bothSidesFalseThe panel’s symmetry toggle

The curve must be closed. An open curve stops the computation with CURVE_MUST_BE_CLOSED; a curve that does not lie in a plane stops it with CURVE_MUST_BE_PLANNAR. The pattern is generated in that curve’s own plane and transformed back, so the outline does not have to sit on the world XY plane.

points is a seed count, not a cell count: edges that fall entirely outside the outline are discarded and edges that cross it are trimmed, so the finished web always has fewer cells than seeds.

Both thickness and height must be greater than zero to get solid geometry. The kernel works in three stages - centre lines, then thickened outlines, then extruded walls - and stops at the stage your parameters reach. With thickness = 0 it produces bare lines; with a thickness but no height it produces flat closed outlines. In neither case is there a solid, and Create returns an empty list having added nothing to the document. Since the model’s own defaults for both are 0, a bare VoronoiApi.Create(curveId) does exactly that. Always pass both:

from ArtisanPlugin.Scripting import VoronoiApi, Transaction

with Transaction.Begin("Voronoi panel"):
    ids = VoronoiApi.Create(curveId, points = 140, thickness = 0.6, height = 1.2)

When the walls resolve to one solid you get a single id: a Voronoi smart component (VoronoiCustomObject, mother = your curve) on the metal layer with the document’s metal material, exactly like the panel’s Accept. When they resolve to several disjoint solids you get several ids, but those are plain breps - routed to the metal layer, without the metal material and without the editable component wrapper. This mirrors the panel, which asks “the result is multiple solids, add anyway?” at that point.

If the thickened outlines cannot be unioned into an outer boundary plus interiors the computation raises NO_SOLUTION; a failure at any stage surfaces as “Voronoi computation failed on that curve.”

bothSides is recorded on the component - it is the symmetry button in the panel - but the current Voronoi computation does not read it, so it changes nothing about the geometry produced.

Every numeric parameter follows the house 0-keeps-default convention: 0 means “use my saved Voronoi defaults, or the tool’s”. No -1 sentinel is needed, because 0 is not a meaningful point count, thickness or height. Passing an id that is not a curve fails with “Object … is not a curve.”

This is a licensed mutation - wrap it in a Transaction for one-step undo.