Scripting API
Thickness
from ArtisanPlugin.Scripting import AnalyzeApi as analyze
The scriptable version of the ArtisanThickness probe: how much metal there is between the point you touch and the far wall behind it. This is the number that decides whether a shank will survive casting, whether a pavé bed still has meat under the seats, and whether a hollowed pendant is thin enough to be worth hollowing. The tool meshes the objects you give it at high resolution and, for each point, casts through the material to find the opposite wall - so the value is the true wall thickness at that spot, not a surface offset.
Both methods are read-only by default. They need no Transaction and no licence. Passing annotate = True changes that: the tool then draws the same purple measure the command leaves behind, which is a document mutation.
One point
mm = analyze.ThicknessAt(objectIds, point, annotate = False) # -> wall thickness in mm
| Parameter | Default | Meaning |
|---|---|---|
objectIds | - | The objects to measure through; they are meshed together |
point | - | A Rhino.Geometry.Point3d on or near the surface |
annotate | False | True also draws the measure into the document |
Returns the thickness in model units - millimetres in a millimetre document. It returns 0 when no measurement is possible at that point, which happens when the ray finds no opposite wall or the measured line is shorter than the document tolerance. Treat 0 as “not measurable here”, not as “zero thickness”.
ThicknessAt is a thin wrapper over ThicknessAtPoints with a one-element list, which means it re-meshes the objects on every call. Measuring twenty points with twenty calls builds the analysis mesh twenty times.
Many points
values = analyze.ThicknessAtPoints(objectIds, points, annotate = False) # -> list of mm
| Parameter | Default | Meaning |
|---|---|---|
objectIds | - | The objects to measure through; meshed once for the whole batch |
points | - | A sequence of Point3d |
annotate | False | True draws one measure per successful point |
The returned list is parallel to points: same length, same order, with 0 in the slots where nothing could be measured. This is the method to reach for whenever you have more than one point, because the high-resolution meshing happens once rather than per point.
from Rhino.Geometry import Point3d
pts = [Point3d(0, 0, 5), Point3d(2, 0, 5), Point3d(4, 0, 5)]
for p, mm in zip(pts, analyze.ThicknessAtPoints(ids, pts)):
print(p, "->", "n/a" if mm == 0 else round(mm, 2))
Annotating
With annotate = True the tool mirrors the command’s own output for each measurable point: a purple line across the wall, a text dot at its midpoint carrying the value and the document’s unit name, and a point at each end - all four added to a group named 2Shapes Measure S<n>, so a single click selects the whole measure. The views are redrawn once at the end.
That is a document mutation, so wrap the call in a Transaction to keep it as one undo step. It also calls the licence gate before doing any work, so an invalid licence fails the whole call rather than leaving half the measures behind.
from ArtisanPlugin.Scripting import AnalyzeApi as analyze, Transaction
with Transaction.Begin("Thickness measures"):
analyze.ThicknessAtPoints(ids, pts, annotate = True)
Errors
Both methods throw before measuring anything:
InvalidOperationException-"No active document."ArgumentException-"At least one object id is required."whenobjectIdsis null or emptyInvalidOperationException-"Could not build an analysis mesh from the given objects."when the objects produce no valid mesh
An empty points sequence is not an error; you simply get an empty list back.