Skip to content

Scripting API

Breakdown tables

from ArtisanPlugin.Scripting import DraftingApi as drafting

The four blocks a production sheet is assembled from: what metal the piece consumes, what stones go into it, what has to be done to it, and what bought-in parts it needs. Each is a view of the same breakdown — the costing object RhinoArtisan computes for the design against the active manufacturer — drawn as plain text into the model space at a point you choose. It is the ArtisanBreakdownMetals / ArtisanBreakdownGems / ArtisanBreakdownProcesses / ArtisanBreakdownExtras commands without their pick prompt, folded into one method because they differ only in which table they draw.

Usage

drafting.CreateBreakdownTable("METALS", point, scale = 0)
ParameterDefaultMeaning
category-METALS, GEMS, PROCESSES or EXTRAS. Trimmed and upper-cased, so "gems" is fine
point-Insertion point: the first row starts here and the table grows downwards
scale0Layout and text-height factor; 0 keeps the tool default, 2

scale follows the house rule: 0 means “the tool default”, which for this table is 2 — the same factor the commands use, and what the report templates draw their list markers at. It multiplies both the row spacing and the lettering, and it scales about point, so the table’s top-left corner stays put as you change it. A negative value throws Scale must be positive.; there is no upper limit, so a large scale simply gives a large table.

The four categories

categoryWhat it draws
METALSOne block per metal in the breakdown, headed by the metal’s name in bold, then four labelled rows: Net weight, Waste, Weight (net plus waste) and Wax, each in grams to two decimals. Blocks are 8 units apart
GEMSThe stone list. Certified diamonds come first, in their own list under a bold Certified title; then the main table, with a header row (Setting, Shape, Num, Size mm, Sieve, Ct, Type) and one row per gem group: a colour swatch keyed to the stone’s size, the setting type, shape, count, size, sieve code, carats, and the diamond type (natural or lab-grown) taken from the document’s setting
PROCESSESOne block per metal — Printing (the print size), Finishing (the finishing type) and Plating (Rhodium or None) — then a bold Setting section listing each setting type with its stone count, and, only when the breakdown has any, a bold Additional processes section listing them by name
EXTRASThe bought-in components, one name per row. Note that this table draws only the names — no title row, no prices

Anything else throws Unknown category 'X'. Use METALS, GEMS, PROCESSES or EXTRAS. — including null and the empty string, so there is no “draw them all” shorthand. Call it four times, at four points, to lay out a full sheet.

Where the breakdown comes from

The tables never compute prices themselves; they render whatever breakdown the document currently holds. When none has been computed yet, or the one stored has no metal rows at all, the breakdown is recomputed first from the active manufacturer — silently, through the same engine PricingApi.Calculate() uses, where the commands would put a yes/no dialog on screen. The freshly computed breakdown is saved back into the document, so the next call finds it.

That test looks only at the metal rows. A design whose breakdown genuinely has no metals — an all-stone parcel, say — is recomputed on every call, which costs time but changes nothing.

When the data behind a table is missing, the table comes out short rather than failing: with an empty gem list GEMS still draws its header row and nothing under it, EXTRAS and the additional-processes section draw nothing at all, and a manufacturer with no pricing rows for a metal simply yields zeros. If the numbers look wrong, fix the manufacturer file and recompute — the table is only a picture of it.

What it returns and where the result lands

The method returns nothing. The result is the text objects added at point, on the active layer, in black, with a doc.Views.Redraw() at the end so they appear immediately.

It throws when there is no active document (No active document.), when the licence is invalid, on an unknown category, and on a negative scale.

from ArtisanPlugin.Scripting import DraftingApi as drafting, Transaction
from Rhino.Geometry import Point3d

with Transaction.Begin("Production sheet tables"):
    drafting.CreateBreakdownTable("METALS",    Point3d(0, 0, 0))
    drafting.CreateBreakdownTable("GEMS",      Point3d(60, 0, 0))
    drafting.CreateBreakdownTable("PROCESSES", Point3d(0, -60, 0))
    drafting.CreateBreakdownTable("EXTRAS",    Point3d(60, -60, 0))

Wrap the calls in a single Transaction so the whole sheet lands as one undo step. If what you actually want is a printable page rather than loose text in model space, use a report template instead: its METAL_LIST, GEM_LIST, PROCESS_LIST and EXTRA_LIST markers draw these same four tables in place — see Reports.