Grasshopper

algorithmic modeling for Rhino

Hi to all,

I'm doing a C# Grasshopper Custom component. I need to access, or better, to use, some of the basic Grasshopper tools/function like this (Point In Curve function).

How can I achieve this?

Thanks in advance.

Robert

Views: 723

Replies to This Discussion

C# doesn't have a node-in-code api (yet) so you either have to:

  1. Duplicate the functionality (which for point in curve isn't too difficult, it's a pretty straight up wrapper around the RhinoCommon method Curve.Contains().)
  2. Create a new GH_Document, add the desired component, populate its inputs, run a solution, harvest the outputs.

Hi David,

Thanks for answering, here my idea and the result:

m_Boundary = array of boundary curves;

m_Mesh = generic mesh;

m_NakedVertex = array of naked mesh edges;

m_Centroid = Point3d of centre of the connection;

for (int i = 0; i < m_Boundary.Count; i++)
{
{
for (int r = 0; r < m_NakedVertex.Length; r++)
{
if (m_NakedVertex[r] == true)
{
Point3d EndPoint = m_Mesh.Vertices[r];
if (m_Boundary[i].Contains(m_Mesh.Vertices[r]) == PointContainment.Inside || m_Boundary[i].Contains(m_Mesh.Vertices[r]) == PointContainment.Coincident)
{
Line line = new Line(m_Centroid, EndPoint);
m_Connections.Add(line);
}
}
}
}
}


RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service