algorithmic modeling for Rhino
Hi,
I think my question is pretty basic but I couldn't find a solution for it online so I am hoping I can get some help from experts.
I am trying to create a C# component in Grasshopper that takes mesh(es) and outputs their vertices (most likely their coordinates). The closest thing I found in RhinoCommon was MeshVertexList.ShowAll Method (which I suppose it just shows the vertices not getting their coordinates). Anyway I used it in my code but each time I receive an error and it is mostly this one:
"Error (CS1061): 'System.Collections.Generic.List<Rhino.Geometry.Mesh>' does not contain a definition for 'Vertices' and no extension method 'Vertices' accepting a first argument of type 'System.Collections.Generic.List<Rhino.Geometry.Mesh>' could be found"
I have 2 questions:
1) What's the best way for coding something that takes some meshes and return their vertices
2) Why do I receive this error or similar errors each time I use a method or property from RhinoCommon and what should I do to fix it?
Thank you in advance for your help!
Tags:
You want code that takes some meshes and returns all of their vertices as a single list, or as separate lists? Or do you want code which takes a single mesh and returns its vertices as a single list of points?
Hi David,
Thank you for your answer. I was looking for a code that takes some meshes and returns all of their vertices in separate lists.
private void RunScript(List<Mesh> M, ref object V)
{
DataTree<Point3d> vertices = new DataTree<Point3d>();
for (int i = 0; i < M.Count; i++)
vertices.AddRange(M[i].Vertices.ToPoint3dArray(), new GH_Path(i));
V = vertices;
}
Thank you very much David. It works nicely!
Is there any Reference or Library for C# grasshopper methods, properties, etc. that you can guide me to? because I tried to use RhinoCommon but it seems to be some problem there, or is there a way that I can fix errors such that I mentioned above?
The Grasshopper dev docs can be downloaded via the Grasshopper help menu. The RhinoCommon documentation is available online: http://developer.rhino3d.com/api/RhinoCommonWin/html/N_Rhino.htm
But it's mostly just the comments from the source code. Ideally the autocompletion in a code editor would help you out the most, but the editor we use in Grasshopper is really bad at providing good intellisense/completion.
Thanks a lot for the answers and your help!
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by