Mesh Component List - Slower in C-Sharp and Python

rhinocommon
grasshopper

#1

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 Vertices.gh (119.6 KB)


(Michael Pryor) #3

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.
Capture
Mesh Vertices.gh (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.


#4

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.


(Michael Pryor) #5

There is a whole SDK for GH_ http://developer.rhino3d.com/wip/api/grasshopper/html/723c01da-9986-4db2-8f53-6f3a7494df75.htm


#6

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.

http://developer.rhino3d.com/wip/api/grasshopper/html/5764fa15-29d1-4e37-8496-2478d3cf28dc.htm