Scripting API
Bend
from ArtisanPlugin.Scripting import TransformApi as transform
Bends objects around the centre of their common bounding box, exactly like the Bend panel. The jewellery move it exists for: take a flat band or a flat pattern and curve it so it follows the finger before you flow it or boolean it into the shank - bend on the default "XY" plane with equal xPos and xNeg, using the amount that matches the finger diameter (DocumentApi.GetRingSize().Diameter). The four distances are the four gumball handles of the panel: each one pulls its side of the bounding box off the bend plane, and the geometry follows as a space morph.
Usage
ids = transform.Bend(objectIds, xPos = 0, xNeg = 0, yPos = 0, yNeg = 0,
plane = None, rigidIds = None, keepOriginal = False) # -> new object ids
| Parameter | Default | Meaning |
|---|---|---|
objectIds | — | Objects to bend; None/empty = the current selection |
xPos | 0 | Millimetres the bounding box’s +X side is pushed along the bend plane’s normal |
xNeg | 0 | Same for the -X side |
yPos | 0 | Same for the +Y side |
yNeg | 0 | Same for the -Y side |
plane | None = "XY" | Bend plane, case-insensitive: "XY" (pushes along world +Z), "ZX" (along world +Y), "YZ" (along world +X) |
rigidIds | None | Objects that must not distort - gems, heads - carried along rigidly |
keepOriginal | False | True leaves the originals in the document |
Positive values lift the side towards the plane normal, negative bend it the other way, 0 leaves that side straight. Pass the same value to a pair (xPos = xNeg) for a symmetric bend - that is all the panel’s Symmetrical and Quad modes do. One BendSpaceMorph is built per non-zero distance, hinged at the bounding-box centre with its handle at the corresponding box face, and the morphs are applied in order: xPos, xNeg, yPos, yNeg. Note that the hinge points themselves are always the box’s X extremes for xPos/xNeg and its Y extremes for yPos/yNeg; plane only chooses which way the handle is pushed.
All four at 0 throws ArgumentException("Nothing to bend: all four distances are 0."). An unknown plane name throws Unknown bend plane 'X'. Use XY, ZX or YZ. If the bend cannot be computed you get an InvalidOperationException reading Bend computation failed., or Bend computation failed: <reason> when the kernel rejected the inputs. Lengths are millimetres throughout.
What you get back, and what is left in the document
The return value is an IReadOnlyList[Guid]: the bent objects first, in the order you passed them, then the rigid ones. Nothing is deformed in place. Every object is baked as a new object carrying the original’s attributes - layer, colour, material, groups - and the originals are then deleted, unless keepOriginal = True, in which case both the originals and the bent copies stay. Objects whose ids no longer resolve are skipped silently rather than throwing.
rigidIds objects do not bend. Each is copied and repositioned with a plane-to-plane transform: a frame at its bounding-box centre is pushed through the same morph, and the object is moved and rotated onto the result. That frame is built from Plane.WorldXY whatever the bend plane is - the panel does this too, and the facade replicates it deliberately. Rigid ids that are not in the document throw Rigid object <id> not found in the document.
An empty or None objectIds falls back to the objects currently selected in the viewport. If that is empty too you get ArgumentException("Nothing to deform: select (or pass) at least one object."), and any id you do pass that is not in the document throws Object <id> not found in the document.
Space morph, so: what survives
This is a Rhino space morph, not a transform. Control points are moved, so the result is only as faithful as the object’s structure allows: a Brep stays a Brep and a curve stays a curve, but analytic faces come back as free-form surfaces, and geometry with few control points bends coarsely - refine the input if the bend looks flat-sided. Extrusions cannot be morphed and are converted to Breps first, so an extrusion you bend comes back as a Brep with a new id. Circles are not rebuilt here (unlike Twist), so a plain four-point rational circle barely deforms; convert it to a denser NURBS curve yourself first. Meshes morph vertex by vertex, at whatever density they already have. Document tolerance settings are not consulted: the morph is applied directly by the tool with its own settings, and nothing about it is exposed to the script.
The whole operation - bake, rigid placement, delete - runs inside a single Rhino undo record named “Artisan Bend” and ends with a viewport redraw, so one Ctrl+Z undoes it. Wrap it in a Transaction when you want it grouped with other mutations as one step.