Skip to content

Scripting API

Auto-dimensions

from ArtisanPlugin.Scripting import DraftingApi as drafting

The one-call version of the drafting job: everything in the document is meshed together at low resolution and annotated, so a bench sheet or a workshop print gets its measurements without a single pick. It is the ArtisanGenerateDimensions command run headless — it takes no arguments because the command takes no input.

Usage

ok = drafting.GenerateDimensions()

There are no parameters. The offset between the geometry and the dimension lines is fixed at 2 mm, and the annotations are drawn with the document’s current dimension style, on the current layer.

What it draws

The method does not ask you what the design is: it reads the document’s design type — the same value SemanticsApi.DescribeDocument() reports, see Document — and branches on it.

Design typeWhat you get
RINGThe ring set: the finger diameter across the bore, the shank’s thickness and width at the bottom, the width and the height at the top, and the shank section’s extent in X
BRACELET, EARRING, NECKLACE, PENDANT, COMPONENT, UNSETThree linear dimensions of the global bounding box: width in X, depth in Y and height in Z, each drawn 2 mm clear of the box at its mid-height

Everything visible or hidden in the document is fed into the analysis mesh — GenerateDimensions has no selection and no selection fallback. If you want to dimension part of a design, use Box dimensions, which takes explicit object ids.

Choosing between this and the specific methods

Call GenerateDimensions when the design type is trustworthy and you want the house default with no decisions to make — a batch that opens a folder of ring files and stamps each one, for instance.

Reach for a specific method instead when you need control the generic entry point does not offer:

  • Ring dimensions — the same branch, but it also halves the dimension style so the annotations read on a small ring, and keeps the dimensions off the metal layer.
  • Box dimensions — bounding-box dimensions of chosen objects, with a settable offset and an optional box Brep.
  • Bangle dimensions — cross sections and inner spans, which the generic branch never produces: a bangle has design type BRACELET, so GenerateDimensions gives it a plain bounding box.

The return value

GenerateDimensions returns a bool: True when the command reported success, False when it failed. Three things make it fail:

  • The licence check did not pass.
  • The objects in the document could not be meshed at low resolution. The command reports this with a modal “Unable to generate dimensions” dialog before failing, which will block an unattended script.
  • The design type is RING but no parametric Artisan ring was found in the document. The finger diameter is read from the first Cathedral, Classic, Signet, curve-driven or Advanced ring object present; with none of those there is no finger size to annotate and the command gives up silently, with nothing added and no message.

A False therefore means the call did nothing — never a partial result. When it returns True, one dimension may still be missing: any annotation whose computed span is degenerate is discarded rather than added, so a perfectly flat object yields fewer than three bounding-box dimensions.

The call mutates the document. Wrap it in a Transaction so the whole set of annotations undoes in one step.

from ArtisanPlugin.Scripting import DraftingApi as drafting, Transaction

with Transaction.Begin("Auto-dimensions"):
    if not drafting.GenerateDimensions():
        print("Nothing was dimensioned.")