Reference layout
Shared reference docs live at mds/reference/ (not under this skill).
- Full path example:
mds/reference/rhino-script-boilerplate.md - Also reachable via:
mds/skills/rhino-document/reference/(symlink)
Routing (mandatory)
| Task | Tool |
|---|---|
| Rhino geometry, layers, selection, bake, materials | rh_run_script |
| Rhino viewport/camera changes | rh_view_control preferred; rh_run_script for advanced one-offs |
| Optional visual QA / viewport screenshot context | rh_capture_view only after permission is granted |
| List Rhino object GUIDs (for GH params) | rh_query_objects |
| Get / reference / internalize Rhino geometry on a GH param | gh_param_rhino |
| Grasshopper components, wires, sliders, GH script nodes | gh_* tools |
If both are needed in one request, use both: rh_run_script for the document, gh_* for the canvas.
When the prompt is vague about Rhino vs Grasshopper scope (e.g. “fix the model”, “clean this up”), use pick_option to ask whether to focus on the Rhino document, Grasshopper canvas, both, or current selection — before editing. An “Other” option is always shown for custom answers; do not add it to the options list.
Visual context and viewport control
rh_capture_viewis optional and permission-gated per Pi session. If capture was not allowed, continue with text and geometry context.- Use visual capture for visual QA, composition, object visibility, display mode/material checks, or ambiguous viewport tasks where pixels materially help.
- Use
rh_view_controlbefore capture when you need a standard view, existing named view, CPlane-aligned plan view, camera/target/lens change, or zoom. - Prefer non-persistent view changes. Only use
rh_view_controlsaveNamedViewwhen the user explicitly asked to create/update a named view. - Default workflow should still work without visual capture: query objects, inspect Grasshopper canvas/errors, and use
rh_run_scriptto print structured RhinoDoc context.
rh_run_script
- command — one-liner macros (
_Circle,_SelLayer, …) - python — preferred for scripts using
rhinoscriptsyntax/scriptcontext; useprint()for return values - csharp — Rhino C# script editor body (Rhino 8 RhinoCode); use
Console.WriteLine()like Python’sprint()
Both script modes run via RhinoCode and return captured stdout to the agent.
Do not call doc.Objects.GetObjectList() with no args in Rhino 8 — use rh_query_objects, rs.ObjectsByType(...), or GetObjectList(ObjectType.AnyObject).
See rhino-script-boilerplate.md — path: mds/reference/rhino-script-boilerplate.md
Rhino → Grasshopper params
rh_query_objects→ short Rhino objectId aliases (4–10 chars), orcountOnly: trueto check how many matchgh_list_componentswithsearchFrom: "params"→ typeGuid (e.g. Curve, Point)gh_edit_componentsadd→ param instance targetId fromgh_get_canvasgh_param_rhino:- Few objects (≤30):
rhinoObjectIdswith short IDs from step 1 - Whole layer / large sets:
rhinoQuery: { layer, objectType?, selectionOnly? }— no ID list in the agent turn (required above 30 objects) referencekeeps live Rhino links;internalizecopies geometry. Usegetto verify (internalized → norhino=on persistent items).- Before internalize on >10 objects or a whole layer (
rhinoQuery), see gh-modeling-expert: User clarification tools.
- Few objects (≤30):
Bulk layer example:
{
"items": [{
"action": "reference",
"targetId": "a1b2",
"rhinoQuery": { "layer": "Geometry::Walls", "objectType": "curve" }
}]
}
Examples
Draw a circle in Rhino (not on GH canvas):
{ "items": [{ "mode": "python", "source": "import rhinoscriptsyntax as rs\nimport scriptcontext as sc\n\ndoc = sc.doc\nids = rs.AddCircle((0,0,0), 10)\nprint(ids)" }] }
Set current layer:
{ "items": [{ "mode": "command", "source": "-Layer Current \"Geometry\"" }] }
Draw a circle in C# (same stdout contract as Python print):
{ "items": [{ "mode": "csharp", "source": "using Rhino;\nusing Rhino.Geometry;\n\nvar doc = RhinoDoc.ActiveDoc;\nvar id = doc.Objects.AddCircle(new Circle(Point3d.Origin, 10));\ndoc.Views.Redraw();\nConsole.WriteLine(id);" }] }
Never
- Use
gh_edit_scriptto run code againstRhinoDoc— that only edits GH script components. - Use
gh_edit_componentsto draw raw Rhino geometry in the viewport.
mds/skills/rhino-document/SKILL.md / View source on GitHub ↗