Grasshopper

algorithmic modeling for Rhino

Any wizards out there able to help me with this?  It may very well be a stupid question but my brain isn't working so well at the moment.

I'm trying to write some code that checks which type of curve is coming into a component.  (arc, linecurve, nurbscurve, etc)

Here's what I have:

public Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.GH_Curve> _curveTree;

//loop through branches

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

            {

 

                //The path

                Grasshopper.Kernel.Data.GH_Path path = _curveTree.Paths[i];

 

                //loop through list

                for (int j = 0; j < _curveTree.Branches[i].Count; j++)

                {

                    GH_Curve gCurve = _curveTree[path][j];

 

                 //check for curve type here - HOW?

 

                }

            }

Any help appreciated, thanks!

Views: 1330

Replies to This Discussion

gCurve will have a Value property that returns a Rhino.Geometry.Curve, you can then query this instance for it's shape or type (i.e. NurbsCurve, ArcCurve, LineCurve, PolylineCurve, Polycurve).

If you want it easy, you can use the converter functions in Grasshopper.Kernel.GH_Convert. The methods ToLine, ToArc, ToCircle etc. will give you lines, arcs and circles even if the curve is merely 'arc-shaped'.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Great thanks David!

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service