Grasshopper

algorithmic modeling for Rhino

Hi

I have the following code based on Rhino 4.Net

but how can i change it to Work with RhinoCommon? 

 

IOnMeshTopology mesh_top =null;

IArrayOnMeshTopologyEdge edges =null;

IArrayOnMeshTopologyFace Faces =null;

IArrayOnMeshTopologyVertex vertices =null;

Mesh.ConvertQuadsToTriangles();

Views: 805

Replies to This Discussion

Mesh mesh_top = null;
Rhino.Geometry.Collections.MeshTopologyEdgeList Edges = null;
Rhino.Geometry.Collections.MeshFaceList Faces = null;
Rhino.Geometry.Collections.MeshTopologyVertexList Vertices = null;
Faces.ConvertQuadsToTriangles();

what about this? you need a valid mesh though.

M.

 Thank you

 

But I still have some problems.

See the hole script below

      

private void MeshOps(Mesh Mesh, out List/font>Point3d> VVertex, out List/font>int> VVertexA, out List/font>int> VVertexB, out List/font>int> VVertexC, out List/font>int> SSupportVertex, out int FFaceCount, out int VVertexCount, out int EEdgeCount)

        {

 

            VVertex =

new List/font>Point3d>();

VVertexA =

new List/font>int>();

            VVertexB =

new List/font>int>();

            VVertexC =

new List/font>int>();

            SSupportVertex =

new List/font>int>();

            FFaceCount = 0;

            VVertexCount = 0;

            EEdgeCount = 0;

           

//IOnMeshTopology mesh_top = null;

           

//IArrayOnMeshTopologyEdge edges = null;

           

//IArrayOnMeshTopologyFace Faces = null;

           

//IArrayOnMeshTopologyVertex vertices = null;

           

//Mesh.ConvertQuadsToTriangles();

           

Mesh mesh_top = null;

            Rhino.Geometry.Collections.

MeshTopologyEdgeList edges = null;

            Rhino.Geometry.Collections.

MeshFaceList Faces = null;

            Rhino.Geometry.Collections.

MeshTopologyVertexList vertices = null;

            Rhino.Geometry.Collections.

MeshFaceList meshFaseList;

            meshFaseList = Mesh.Faces;

            meshFaseList.ConvertQuadsToTriangles();

           

           

////////////////////////////////Mesh Operations

           

Point3f fpoint = new Point3f();

           

//mesh_top = Mesh.Topology();

           

//Faces = mesh_top.m_topf;

           

//vertices = mesh_top.m_topv;

           

//edges = mesh_top.m_tope;

            mesh_top = Mesh;

            Faces = mesh_top.Faces;

            vertices = mesh_top.TopologyVertices;

            edges = mesh_top.TopologyEdges;

           

for (int i = 0; i < vertices.Count(); i++)

            {

fpoint = mesh_top.TopVertexPoint(i);

               

Point3d fto3d = new Point3d(fpoint.X, fpoint.Y, fpoint.Z);

                VVertex.Add(fto3d);

            }

           

for (int i = 0; i < Faces.Count(); i++)

            {

               

Int32[] vertexArray = new Int32[3];

                mesh_top.GetTopFaceVertices(i, vertexArray);

                VVertexA.Add(VVertexCount + vertexArray[0]);

                VVertexB.Add(VVertexCount + vertexArray[1]);

                VVertexC.Add(VVertexCount + vertexArray[2]);

            }

           

for (int i = 0; i < edges.Count; i++)

            {

               

//IOnMeshTopologyEdge mesh_edge = edges[i];

                Rhino.Geometry.Collections.

MeshTopologyEdgeList mesh_edge = edges[i];

               

if (mesh_edge.m_topf_count == 1)

                {

                   

int p1 = mesh_edge.get_m_topvi(1);

                    SSupportVertex.Add(EEdgeCount + p1);

                }

            }

            FFaceCount = Faces.Count();

            VVertexCount = vertices.Count();

            EEdgeCount = edges.Count;

        }

Faces = mesh_top.Faces;

Vertices = mesh_top.TopologyVertices;

Edges = mesh_top.TopologyEdges;

see http://4.rhino3d.com/5/rhinocommon/html/AllMembers_T_Rhino_Geometry...

for the rhinocommon mesh class members

Thank you, I also found that shortly after my last post

 

However how to access this

fpoint = mesh_top.TopVertexPoint(i);

any specific error cause I don't have rhino at hand right now.

mesh_top.TopVertexPoint(i);

mesh_top.GetTopFaceVertices(i, vertexArray);

are not working

mesh_top.TopologyVertices(i);

mesh_top.MeshFaceList.GetTopologicalVertices(i);

Not tested!! so use with caution .

Thank you

 

And the last part I'm missing is this

           

for (int i = 0; i < edges.Count(); i++)

            {

             

IOnMeshTopologyEdge mesh_edge = edges[i];

               

if (mesh_edge.m_topf_count == 1)

                {

                   

int p1 = mesh_edge.get_m_topvi(1);

                    SSupportVertex.Add(EEdgeCount + p1);

                }

            }

Where these 3 lines are causing errors

edges[i];

mesh_edge.m_topf_Count

mesh_edge.get_m_topvi(1);

And further I cannot access the edge like this

               

MeshTopologyEdgeList mesh_edge = edges[i];

as i did in the old script

 

I get the following error:

Cannot apply indexing with [] to an expression of type 'Rhino.Geometry.Collections.MeshTopologyEdgeList'

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service