Skip to content

Scripting API

Metals table

from ArtisanPlugin.Scripting import DraftingApi as drafting

The weight table a caster reads before quoting: the same piece weighs one thing in 18K yellow and quite another in platinum, so the sheet lists the estimated cast weight of the design in each metal you care about, plus what is left of it once the piece has been polished. It is the ArtisanMetalsList / ArtisanMetalsListBySelection commands without their checklist dialog and pick prompt: the tool measures the volume of the objects once, then multiplies that single volume by each metal’s density.

Usage

drafting.CreateMetalsTable(point, ["GOLD_YELLOW_18", "PLATINUM", "SILVER"],
                           includeWax = True, onlySelection = False)
ParameterDefaultMeaning
point-Insertion point; the header row sits on it and the table grows downwards
metals-Metal enum names to list, case-insensitive. Rows always follow the checklist order, whatever order you pass
includeWaxFalseTrue appends the wax row, at the configured wax density
onlySelectionFalseTrue measures only the current selection (ArtisanMetalsListBySelection); False measures every non-hidden object in the document

There is no scale parameter here: the rows are 1.5 model units apart and the texts take the document’s current annotation style. To draw the table larger, scale the resulting texts afterwards, or use the breakdown tables, which do take a scale factor.

The metals it accepts

metals is a subset of the command’s checklist, and nothing else is accepted:

GOLD_24
GOLD_YELLOW_22   GOLD_YELLOW_18   GOLD_YELLOW_14   GOLD_YELLOW_10   GOLD_YELLOW_9
GOLD_WHITE_18    GOLD_WHITE_14    GOLD_WHITE_10    GOLD_WHITE_9
GOLD_ROSE_18     GOLD_ROSE_14     GOLD_ROSE_10     GOLD_ROSE_9
GOLD_GREEN_18    GOLD_GREEN_14    GOLD_GREEN_10    GOLD_GREEN_9
GOLD_CHOCOLATE   PLATINUM         SILVER           PALLADIUM

These are the metals you ask for, not the metals the document carries: the table is a what-if list, so the design’s own metal assignment plays no part in which rows appear. Anything outside the list throws Unknown metal 'X'. Valid values: GOLD_24, GOLD_YELLOW_22, ..., and asking for nothing at all — an empty list, or only blank names, with includeWax = False — throws At least one metal (or the wax row) is required.

How the weights are estimated

The tool sums the volume of the measured objects, skipping anything that is a gem or diamond. Breps, extrusions (both through their Brep form), meshes and SubDs (meshed via ToBrep) contribute; curves, points, text and everything else contribute nothing. Volumes are taken as absolute values, so an inside-out solid still adds rather than subtracts.

That single volume then becomes a weight per metal, in grams, at density in g/cm³ over a volume in mm³:

ColumnContents
NameThe translated metal name, left-aligned at the insertion point
Weightvolume x density / 1000, formatted 0.00 g, right-aligned 20 units in
Processed (-5%)The same weight with the configured processed-weight percentage removed, right-aligned 34 units in

The header row reads Weight and Processed (-N%), with the actual configured percentage — 5% unless you have changed it in Options. Densities come from RhinoArtisan’s table, or from your Custom Metal List when one overrides that metal. The wax row uses the configured wax density (0.97 by default) with the carat-style divisor the wax estimate has always used, and deliberately has no Processed value, so its third column is left blank.

Every text is added to the active layer with an explicit black object colour, and all of them join one new, unnamed group — unlike the gems and breakdown tables, there is no group name to search for afterwards. Select one text and press Ctrl+Shift+G, or select the group in the ungrouped state, to move or delete the table as a unit.

What it returns and when it throws

The method returns nothing. The result is the texts left in the document at point, and 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 metal or an empty request as described above, and when there is nothing to measure: Nothing is selected. with onlySelection = True, There are no objects in the document. otherwise.

Missing data is not an error, only missing objects. A document holding nothing but gems passes the object check, contributes zero volume and draws a full table of 0.00 g rows — a sign that the tool found no metal geometry, not that the settings are wrong.

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

with Transaction.Begin("Metals table"):
    drafting.CreateMetalsTable(Point3d(60, 0, 0),
                               ["GOLD_YELLOW_18", "GOLD_WHITE_18", "PLATINUM"],
                               includeWax = True)

The table is a document mutation like any other: wrap it in a Transaction so the whole table lands as one undo step.