Grasshopper

algorithmic modeling for Rhino

Hi

 

I have been working on a script where the index of the vertices of a mesh is quite vital. In the process I have found a quite weird difference between the Weaverbird vertex component and the Rhino.Geometry.Collections.MeshVertexList.ToPoint3dArray(). The order of the vertices in the two cases are different.

I have made a testcomponent that has the vertices of a mesh as output. I then draw a poyline between vertices to show the difference. See picture: Top is Rhino.Geometry. Bottom is WeaverBird. Anyone who knows why this is the case?

 

 

And heres the code

 

namespace

VerticesTest

{

   

using System;

   

using Grasshopper.Kernel;

   

using Rhino;

   

using Rhino.Geometry;

   

public class VerticesTest : GH_Component

    {

       

private Point3d[] vertices;

       

public VerticesTest()

            :

base("TestMyVertices", "VerticesTest", "Component made to show the difference between Weaverbirds and Grasshoppers different way of recognizing vertices", "Extra", "TestStuff")

        {

        }

       

protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)

        {

            pManager.AddMeshParameter(

"Mesh", "M", "Mesh for test", GH_ParamAccess.item);

        }

       

protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)

        {

            pManager.AddPointParameter(

"Vertices", "V", "TestOutputforMeshgeneration", GH_ParamAccess.list);

        }

       

       

protected override void SolveInstance(IGH_DataAccess DA)

        {

            Rhino.Geometry.

Mesh mesh = null;

           

if (!DA.GetData(0, ref mesh)) { return; }

           

if (!mesh.IsValid) { return; }

            vertices = mesh.Vertices.ToPoint3dArray();

           

            DA.SetDataList(0, vertices);

        }

       

       

public override Guid ComponentGuid

        {

           

get { return new Guid("DA410557-D5CE-4457-914D-F594F64FA978");

        }

        }

    }

}

 

 

Views: 1130

Attachments:

Replies to This Discussion

Hi Timo

welcome to scripting meshes. And thanks for trying Weaverbird.

The reason is that Weaverbird by default uses the welded state of the mesh, so if you change the (W) input in the mesh to False, the two results should be the same.

I hope this helps,

Giulio

--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

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