Skip to content

Python package

Errors and transactions

ra.transaction()

with ra.transaction("Move the side stones"):
    for g in ra.gems.selected():
        g.move((0, 0, -0.5))

Every change made inside the block is one undo step. Leaving the block — normally or by exception — closes the undo record. Mutations need a valid license; read-only calls never do.

Errors

All of them are plain Python exceptions too (except Exception catches them); the message is on str(e) and e.Message.

ErrorUnderlying typeWhen
ra.ValidationErrorScriptingValidationExceptionAn argument was rejected before anything was computed: wrong enum name, value out of range, unknown id, malformed JSON.
ra.ComputeErrorScriptingComputeExceptionThe arguments were accepted but the kernel could not build the geometry; .Code carries the kernel key (e.g. INVALID_PROFILE).
ra.StateErrorScriptingStateExceptionThe document is not in a state where the call makes sense: no active document, the object no longer exists, nothing is selected.
ra.LicenseErrorScriptingNotLicensedExceptionThe call needs a valid RhinoArtisan license.

ra.ArgumentError is the base of ValidationError, ComputeError and LicenseError (System.ArgumentException).