Skip to content

Scripting

visose edited this page Jun 28, 2026 · 1 revision

Robots can be used from Grasshopper, Rhino scripting, and .NET applications.

Packages

  • Robots is the core .NET 8 package. It uses Rhino3dm and can run outside Rhino.
  • Robots.Rhino is for developing Rhino and Grasshopper plug-ins against Robots and RhinoCommon.

Use the Grasshopper plugin for visual programming. Use the packages when you need automation, batch generation, integration with another application, or custom plugin code.

The same validation principle applies outside Grasshopper: create a Program, inspect Errors and Warnings, then save or upload only after review.

Basic .NET shape

using System;
using Rhino.Geometry;
using Robots;

RobotSystem robot = FileIO.LoadRobotSystem("ExampleCell", Plane.WorldXY);

JointTarget home = new([0, 0, 0, 0, 0, 0]);
CartesianTarget target = new(
    Plane.WorldXY,
    motion: Motions.Linear,
    zone: new(5));

SimpleToolpath toolpath = new([home, target]);
Program program = new("TestProgram", robot, [toolpath]);

if (program.Errors.Count > 0)
{
    foreach (string error in program.Errors)
        Console.Error.WriteLine($"Error: {error}");
}
else
{
    foreach (string warning in program.Warnings)
        Console.WriteLine($"Warning: {warning}");

    program.Save(@"C:\Temp\RobotProgram");
}

The example is written as a self-contained C# snippet. If System, Rhino.Geometry, or Robots is already imported by your Grasshopper script or project-level global usings, keep a single import rather than duplicating it. In a standalone top-level .NET file, Program may conflict with the generated application type; qualify it as Robots.Program in that case. The same model applies in Rhino C#, Python, or VB.NET scripts, but syntax differs by language.

Useful scripting-only features

Some features are easier to reach from scripts than from Grasshopper components:

  • Custom postprocessors through IPostProcessor.
  • Custom external-axis output with ExternalAxes.Custom(...).
  • ABB unspecified external axes with ExternalAxes.AbbUnspecifiedAxes(count).
  • Loading robot systems without meshes for faster non-visual checks.
  • Batch generation of many programs or variants.

Custom postprocessors

Load Robot System accepts an optional postprocessor input. In code, FileIO.LoadRobotSystem also accepts an IPostProcessor. This lets advanced users keep the kinematics and checking pipeline while replacing the final code-generation step.

Unsupported controller features should become explicit program errors. Missing motion, frame, tool, IO, or command semantics should not disappear silently from generated code.

Working outside Rhino

The core Robots package is intended for non-Rhino .NET 8 applications and uses Rhino3dm geometry types. It can load libraries, solve programs, generate code, and use custom mesh posing integrations.

Use Robots.Rhino only when you are building Rhino or Grasshopper plug-ins and need RhinoCommon integration.

Related Pages

Clone this wiki locally