Scripting API
Calculate
from ArtisanPlugin.Scripting import PricingApi as pricing
Calculate answers “what does this piece cost?” without opening a panel. It runs the same Breakdown engine the Breakdown panel uses — the same BreakdownService compute path — against the current document and the active manufacturer and market, and returns the grand total plus one number per cost category: metal, certified diamonds, gems, processes and extras. Because it is the same engine, the number a script reports and the number the panel shows can never diverge.
Usage
result = pricing.Calculate() # -> a PriceResult
offline = pricing.Calculate(quoteCertified=False)
| Parameter | Default | Meaning |
|---|---|---|
quoteCertified | True | True fetches live Nivoda quotes for every certified diamond, exactly like the panel. False skips the quotes: fast and fully offline, but those stones price as 0 |
The quoteCertified flag
A certified diamond is any diamond at or above the active manufacturer’s CertificateFromCt threshold — those stones are not priced from the manufacturer’s size and sieve tables but from a live market quote. With quoteCertified=True (the default) each of them is quoted against the Nivoda service using your saved Nivoda filter, which means a network round trip per calculation and a total that matches the panel. With False there is no network traffic at all; the certified stones still count in the piece but contribute 0 to Diamonds and to Total, so the result is a floor, not a quote. Use False in tight loops (parametric sweeps, batch reports) and one final True call for the real number.
What it returns
A PriceResult. All monetary fields are plain double values in the active manufacturer’s currency — the Currency field tells you which one; nothing is converted.
| Field | Type | Meaning |
|---|---|---|
Currency | str | The manufacturer’s currency code, e.g. "EUR". Empty if the manufacturer declares none |
Total | float | The grand total — the sum of the five categories below |
Metal | float | Metal cost: weight plus waste at the market’s spot price |
Diamonds | float | Certified diamonds total. 0 for the unquoted stones when quoteCertified=False |
Gems | float | Gemstones total, priced from the manufacturer’s per-size and per-sieve tables |
Processes | float | Labour and processes: printing, cast-finish-polish, finishing, rhodium, setting labour and additional processes |
Extras | float | Extra components (findings, chains, boxes…) |
TotalFormatted | str | Total already rendered with the currency symbol, e.g. "1,234.00 €". str(result) returns the same string |
Need the individual lines behind these totals — per metal, per stone, per process? Use CalculateDetailed, which runs the identical computation and returns everything itemised.
Side effects and errors
Calculate never touches geometry, layers or settings, and it needs no Transaction — but it is not a pure read either: it recomputes and replaces the document’s cached breakdown, the same one the Breakdown panel displays. Call ShowPanel afterwards and the panel shows exactly what you just computed.
It throws rather than returning a guess:
- no open document — “No active document.”
- the engine could not produce a breakdown (typically no active manufacturer or an empty document) — “Pricing could not be computed for this document.”