Scripting API
Bangle dimensions
from ArtisanPlugin.Scripting import DraftingApi as drafting
What a bangle drawing has to state: the section of the band at the top, the bottom and each side — width and thickness at every one of them — and the size of the hole the wrist goes through. The objects you pass are meshed together at low resolution, sliced with the two world planes through the origin, and annotated. It is the ArtisanGenerateDimensionsFromBangle command with its selection prompt and its options turned into arguments.
Usage
drafting.GenerateDimensionsFromBangle(objectIds, offset = 2.0, addBox = False)
| Parameter | Default | Meaning |
|---|---|---|
objectIds | — | The objects to dimension, the command’s selection. At least one id is required; there is no fallback to the viewport selection |
offset | 2.0 | Gap in millimetres between the geometry and the dimension lines, the command’s Offset option. Valid from 0 to 100 |
addBox | False | True also adds the global bounding box to the document as a Brep, the command’s Box option |
offset is a literal gap, not a sentinel: 0 puts the dimension lines flush against the geometry.
What it draws
The mesh is cut twice: with the world YZ plane, which gives the sections at the top and the bottom of the band, and with the world XY plane, which gives the sections at the right and the left. Each of the four gets two dimensions, not one:
| Section | Dimensions |
|---|---|
| Top | Its width in Y, and its thickness in Z |
| Bottom | Its width in Y, and its thickness in Z |
| Right | Its width in Y, and its thickness in X |
| Left | Its width in Y, and its thickness in X |
Two further dimensions span the model:
- Across X, drawn above the model, clear of the bounding box by twice the offset.
- Across Z, drawn at the model’s side, likewise clear by twice the offset.
These two are measured from the inner edges of the sections — the innermost X of the right section to the innermost X of the left, and the lowest Z of the top section to the highest Z of the bottom. They therefore report the inner opening, the aperture the wrist passes through, not the outside width and height of the piece. The old single-page reference called them “the global spans”, which is wrong in both directions: they are not global, and they are internal. If you want the outside envelope, pass addBox = True and measure the Brep, or use Box dimensions.
That makes ten dimensions in total on a well-formed bangle. Each one is added only when it comes out geometrically valid: a section that lands entirely on one side of a cutting plane produces an empty bounding box, whose dimensions are silently dropped. A short result is a symptom of an off-centre or open bangle, not an error you will be told about.
Everything lands on the current layer, with the document’s current dimension style — the style is left alone, unlike Ring dimensions. Note also that, unlike Box dimensions, no analysis mesh and no marker point are left behind: only the dimensions, plus the bounding-box Brep when you ask for it.
The return value
GenerateDimensionsFromBangle returns nothing (void). To see what it produced, diff the document’s object ids around the call:
import Rhino
from ArtisanPlugin.Scripting import DraftingApi as drafting, Transaction
doc = Rhino.RhinoDoc.ActiveDoc
before = set(o.Id for o in doc.Objects)
with Transaction.Begin("Bangle dimensions"):
drafting.GenerateDimensionsFromBangle(ids, offset = 2.0)
created = [o for o in doc.Objects if o.Id not in before]
print(len(created), "annotations") # ten on a well-formed, centred bangle
The Transaction also gives the whole set a single undo step, which matters here more than usual: ten annotations are tedious to remove by hand.
Validation
Failures are exceptions, not a return code:
| Condition | Error |
|---|---|
| No document open | No active document. |
offset below 0 or above 100 | Offset must be between 0 and 100. (an ArgumentOutOfRangeException) |
objectIds empty or None | At least one object id is required. |
| The objects cannot be meshed at low resolution | Unable to generate dimensions from the given objects. |
There is no check that the objects are actually a bangle. Passing something else — a ring, a pendant, a lone sphere — throws nothing: it is cut with the same two planes and whatever sections happen to fall in each half-space get dimensioned, which is rarely what you want.