C# Programming Basics

HI All,
I am not new to Rhino but new to try and develop Plugins .
I have installed Visual Studio and worked through MyFirstPlugin

I am unsure how to run the examples codes that are listed.
Can anybody please help me with a complete code for say the Circle?

Cheers Leigh

You plug-in should have at least one command, which looks like this:

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
  // command code here
}

The code from any example can be inserted there. For example, to add a circle, I’ve taken the code from Rhino - Add Circle and added it inside the RunCommand like so:

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
  Rhino.Geometry.Point3d center = new Rhino.Geometry.Point3d(0, 0, 0);
  const double radius = 10.0;
  Rhino.Geometry.Circle c = new Rhino.Geometry.Circle(center, radius);
  if (doc.Objects.AddCircle(c) != Guid.Empty)
  {
    doc.Views.Redraw();
    return Rhino.Commands.Result.Success;
  }
  return Rhino.Commands.Result.Failure;
}

Good luck on finding your wings with C# programming :slight_smile:

1 Like

Thank you so much Menno
This was a greathelp :+1:

1 Like