Scripting API
Cost settings
from ArtisanPlugin.Scripting import PricingApi as pricing
Everything the Breakdown engine charges comes from the active manufacturer: Markets (the Gold, Silver, Platinum and Palladium spot prices), Metals, Diamonds (the per-size and per-sieve price tables and the CertificateFromCt threshold), Printing, Cfp (cast-finish-polish), AdditionalProcesses, GemSetting (labour per setting type) and Timing. It persists as Manufacturer.json in the pricing folder. These three methods let a script read that tree, change one value in it, and show the resulting breakdown in the panel — the scripted equivalent of updating this morning’s gold fix before quoting.
GetSettingsJson
pricing.GetSettingsJson() # the whole manufacturer
pricing.GetSettingsJson("Markets") # just the spot prices
pricing.GetSettingsJson("Diamonds.CertificateFromCt") # a single value
pricing.GetSettingsJson("Cfp.Items[2]") # one row of a table
| Parameter | Default | Meaning |
|---|---|---|
path | None | A path into the settings tree, or None (or blank) for the entire manufacturer |
Returns the node at path serialised as indented JSON (a Python string — parse it with json.loads if you want a dict). Purely a read: nothing is computed, cached or written, no Transaction, no licence gate.
Path syntax
- Segments are separated by dots:
Diamonds.CertificateFromCt. - Names are case-insensitive (
markets.goldworks) and match the C# property names you see in the JSON output; surrounding whitespace in a segment is trimmed. - List items are indexed with
[n], zero-based, appended to the list’s name:Cfp.Items[2], and you can keep walking past it:Cfp.Items[2].Price.
The honest workflow is discovery first: dump a level with GetSettingsJson, read the property names off the JSON, then build the path from what you saw. A wrong name is an error, and a helpful one — it lists what actually exists at that level: “‘Golde’ not found under ‘Markets’. Available: Gold, Silver, Platinum, Palladium…”. Other failures: “No active manufacturer.” when there is none, “Invalid list index in ‘Items[x]’.” for a malformed index, “‘Items’ has 3 item(s); index 5 is out of range.”, “‘Items’ is not a list.” when you index a non-list, and “‘X’ is empty at ‘path’.” when an intermediate node is null.
SetSetting
pricing.SetSetting("Markets.Gold", "68.5")
pricing.SetSetting("Diamonds.CertificateFromCt", "0.30")
result = pricing.Calculate() # prices with the new values
| Parameter | Default | Meaning |
|---|---|---|
path | — | The path of one value, same syntax as GetSettingsJson |
value | — | The new value as a string; converted to the target’s type |
Updates exactly one value and persists the manufacturer: the change is applied as the active pricing and written back to Manufacturer.json in the pricing folder. That makes it a global, persistent change — it affects every document priced against this manufacturer from now on, not just the open one — and it survives closing Rhino. It is not part of the document’s undo stack and needs no Transaction; to roll it back, set the old value again (read it first with GetSettingsJson). The next Calculate() prices with the new value.
value is always passed as a string and converted with invariant culture to whatever type the target property has:
- numbers —
"68.5","0.30"(decimal point, not comma) - booleans —
"true"/"false" - strings — passed through as-is
- enums — the enum member’s name, case-insensitive
A string that does not convert throws “‘abc’ cannot be converted to Double for ‘Markets.Gold’.”.
The path must land on a single writable value, not a container. Pointing at a whole list item throws “‘Items[2]’ is a whole list item — set one of its values instead (e.g. Items[2].Price).”; a read-only leaf throws “‘X’ is not a settable value at ‘path’.”; an empty path throws “A settings path is required, e.g. Markets.Gold.”. All the navigation errors from GetSettingsJson apply too, plus “No active manufacturer.”. Because it writes, SetSetting is licence-gated: it raises ScriptingNotLicensedException before touching anything.
ShowPanel
pricing.Calculate()
pricing.ShowPanel()
Opens the Breakdown panel — the interactive price-details view in the Rhino UI. It takes no parameters, returns nothing and computes nothing; it simply shows whatever breakdown the document currently holds. In a scripting context its job is visual inspection: after a Calculate() or CalculateDetailed() the panel displays the freshly computed totals, so a script can change a cost, recompute, and put the itemised result in front of the user without them touching the ribbon. It must run on the UI thread (Flow Studio’s Apply does; ordinary editor scripts do too).