Grasshopper

generative modeling for Rhino

# check for curve type C#?

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: 163

### 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

Great thanks David!

• View All

## Videos

• ### Rhino3D Grasshopper Tutorial 14 - Expressions 01

Added by Jose Sanchez

• ### Rhino3D Grasshopper Tutorial15 Expression 02

Added by Jose Sanchez

• ### Rhino3D Grasshopper Tutorial16 - Geometric Orientation

Added by Jose Sanchez

• ### PYTHON in Grasshopper 02 Recursive Aggregation

Added by Jose Sanchez

• ### PYTHON in Grasshopper 01 Koch Curve

Added by Jose Sanchez