Is it possible to use rhino developer docs samples in C# grasshopper?

Hi Erveryone,

I must admit I only know very little about coding, but I want to know if it’s possible to use any of the samples on rhino docs in the C# component:

As an example I would love to use this script in gh:

Thank you,
Thomas

private void RunScript(Mesh mesh, List<Point3d> points, Vector3d vector, ref object A)
{
  int[] indices;
  var prj_points = Intersection.ProjectPointsToMeshesEx(new[] {mesh}, points, vector, 0, out indices);
  A = prj_points;
}

ProjectPointsToMesh.gh (9.7 KB)

Hi Mahdiyar,

Thank you so much. This is great!
…eventhough I still don’t get how you did it :slight_smile:
But I guess I should look into C# coding or ?

Cheers,
Thomas

Dear @toh
the developer samples you quote are for plug-in development. As Plug-ins target to be rhino-commands and not grasshopper components the sections of the script that handle the input and output are different.
But
the section that handles the geometry is the same for a rhino-c#-plug-in-command and a Grasshopper component.
for the example you mentioned:

 var prj_points = Intersection.ProjectPointsToMeshesEx(new[] {mesh}, points, new Vector3d(0, 1, 0), 0, out indices);
   

of course can be used inside a grasshopper c# script or grasshopper component.
you may also want to check out
https://developer.rhino3d.com/api/grasshopper/html/730f0792-7bfb-4310-a416-239e8c315645.htm

kind regards -tom

Hi @Tom_

Great thank you so much. This makes sense I think :slight_smile:

But is it possible to find a “library/overview” of all the variables that I can use in a C# script / component?

I’m gonna check out your link,

Kind regards
Thomas

thats your starting-point:

https://developer.rhino3d.com/api/RhinoCommon/html/R_Project_RhinoCommon.htm

1 Like

Uhhh biig library :slight_smile: - amazing!