Skip to content

Scripting API

Gems table

from ArtisanPlugin.Scripting import DraftingApi as drafting

The same stone list as the CSV export, but drawn into the model so it prints alongside the views on a production sheet: one row per distinct gem with shape, size, carats, quantity, total carats and compound. The tool collects the gems, groups identical stones, and lays the rows out as plain text objects - the ArtisanGemsList command family, headless.

Usage

drafting.CreateGemsTable(point, onlySelection = False, groupBySelection = False)
ParameterDefaultMeaning
point-Point3d the table is drawn from: the first row’s left edge, rows running downwards
onlySelectionFalseTrue = only the currently selected gems (ArtisanGemsListBySelection); False = every visible gem in the document (ArtisanGemsList)
groupBySelectionFalseTrue = the ArtisanGemsListBySelectionGroups variant: the selected gems are bucketed by their Rhino group and drawn as one sub-table per group, each headed by the group’s name in capitals, plus an “Ungrouped” section for selected gems belonging to no group. Implies onlySelection

Placement and size

point is applied as a plain translation of a table laid out from the world origin, so it is the top-left of the block: the first row sits at point, and each following row is 1.5 model units lower. Columns are at fixed offsets from point in X - shape at 0, size at 12, carats right-aligned at 29, quantity centred at 33, total carats right-aligned at 42, compound at 46 - so the block is roughly 46 units wide. In a millimetre document that is millimetres.

There is no scale parameter on this method, unlike breakdown tables: row spacing, column offsets and text height are fixed, the text height coming from the document’s default annotation style. Scale the resulting group afterwards if you need the table bigger. Every text is drawn in black, with the object colour set explicitly rather than inherited from the layer.

In the grouped variant, the sub-tables run one after another down the same column, separated by one blank 1.5-unit row, each preceded by its group-name header row; the “Ungrouped” section comes last.

What you get back

Returns nothing (void). The result is the text objects added to the active document, collected into a Rhino group named GEMS_LIST - or GEMS_LIST_BY_SELECTION_GROUPS for the grouped variant. That is how you find, move or delete the table afterwards; each call adds a fresh one rather than updating the last. The views are redrawn on the way out.

Errors

With no document open it throws InvalidOperationException “No active document.”

With no visible gems in the document it draws nothing at all - like the command, that is not an error. The selection variants, though, throw ArgumentException “No gems in the current selection.” when the selection holds no gems, mirroring the commands’ cancel.

The table is document geometry: wrap the call in a Transaction for one-step undo.