Purpose
Scripts that are readable, testable, and safe to run on a live model.
The standard
Python 3 (Rhino 8
_ScriptEditor) withrhinoscriptsyntaxfor simple ops andRhinoCommon(Rhino.Geometry) for anything geometric or performance-sensitive.Structure:
tool_name/package withcore/(pure geometry math, no Rhino imports — unit-tested with pytest outside Rhino),rhino/(document I/O), andrun.pyentrypoint.Every script: starts with a docstring (what, inputs, outputs, layers touched), wraps changes in an undo record (
sc.doc.BeginUndoRecord/EndUndoRecord), and prints a one-line summary at the end.Inputs via
rs.GetObjects/GetOptionor a small Eto dialog; never hard-coded paths. Config in asettings.jsonnext to the script.Writes to
TMP::or explicit output layers only; never modifies input geometry without an option.Follows 04.02 for style;
printallowed for the Rhino console.
Procedure — new tool
Scaffold from template-rhino-plugin → write core/ with tests → wire rhino/ → add a catalog page (10.06) → package (06.07).
Anti-patterns
800-line single scripts; rs.AllObjects() on a large model; catching all exceptions and continuing.
Owner: [TEAM] · Last reviewed: 2026-09