Mesh Component List - Slower in C-Sharp and Python

Hi, recently I been learning a bit of c#, I was trying to do some basic operation on meshes using the c# component but it seems to be slower than expected, when I extract the VertexList, the c# component seems to take the same time than the python one, and they both are a lot slower than the Mesh Deconstruct component , this varies depending on the input mesh. Does anyone know, why this difference in solution time, and if there is any faster way of extracting mesh components. Thanks

Mesh (119.6 KB)

It is the use of Grasshoppers geometry types as opposed to rhinocommon. GH_Point

See here a quick test just testing the verts of M.Vertices VS a for loop for a list of GH_Point.

The GH_Point version does not even register on the profiler.
Mesh (118.9 KB)

List<GH_Point> verts = new List<GH_Point>();

for(int i = 0; i < M.Vertices.Count; i++)
  verts.Add(new GH_Point(M.Vertices[i]));

V = verts;

Also keep in mind for C# components if you open then close the editor it runs slow the first time. Then just recompute grasshopper for the real speed.


Hi, thanks, that pretty much make my day, so GH_Types are only for outputting geometry from the component? or they can be use with methods of Rhinocommon later in the script. So for example if you were to create a new mesh with those GH_Points.

There is a whole SDK for GH_

1 Like

Nice, here is the answer, Thanks

As I mentioned before, the first input parameter is of type Param_Circle and it contains data of type GH_Circle. But when we’re accessing the parameter via the DA.GetData(0, circle) method, we’re using Rhino.Geometry.Circle instead of GH_Circle. The DA.GetData() method is capable of converting data from the intrinsic parameter type into requested types, provided the conversion makes sense. GH_Circle to Rhino.Geometry.Circle is a perfectly valid conversion, GH_Circle to Rhino.Geometry.Transform would not be.

1 Like