rhino_execute_csharp
Run RhinoCommon C# scripts in a live Rhino session. Automate geometry creation, modification, and analysis with full access to Rhino document and objects.
Instructions
Execute RhinoCommon C# code in a live Rhino session using Roslyn.
SAFETY: This tool runs arbitrary code with full RhinoCommon access.
It is gated behind ``RHINO_MCP_ALLOW_CSHARP=1`` so it cannot fire
accidentally. Set the env var only in trusted sessions.
Globals available to the script:
- ``doc``: the active ``RhinoDoc``
- ``output``: a ``StringBuilder`` — call ``output.AppendLine("...")``
to return text to the caller.
Pre-imported namespaces: System, System.Collections.Generic,
System.Linq, System.Text, Rhino, Rhino.Geometry, Rhino.DocObjects,
Rhino.Commands. Pass ``references`` to load extra assemblies (e.g.
``Grasshopper``).
Example — create a sphere::
var sphere = new Sphere(Point3d.Origin, 5.0);
doc.Objects.AddBrep(sphere.ToBrep());
doc.Views.Redraw();
output.AppendLine("Created sphere");
Changes are wrapped in an undo record. ``timeout_s`` caps total
execution time (default 30s); on timeout the call returns
``success: false`` and the script is best-effort cancelled.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| args | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||