Surface edges: what are the curve types?

My question: Is there a way to know or get the exact type of curve of an Autodesk.DesignScript.Geometry.Edge?

Hi all!

What I want to do is to convert Dynamo’s surface geometry into another format that I can process later on. For this it is needed to know the curve type of the edge(s), such as Line, Arc, Circle, NurbsCurve, PolyCurve, etc.

For a regular curve I can do:

string curveType = curve.GetType().Name;  //results in curve type like Line, Arc, ...

But for an edge this will always result in ‘Curve’:

string edgeType = edge.CurveGeometry.GetType().Name;  //results in 'Curve'

I’d rather not start comparing my edges and curves list of each surface to determine if an edge is a curve based on it’s properties. I don’t think this is a foolproof method.

Does anyone have an idea? Thanks again guys!!!

Michael

How are you retrieving the edges? Might be that you need to step further back in the graph to maintain those curve types.

a workaround with Explode()

2 Likes

Thanks @Michael684 for the feedback. The fix will be available in the next release (2.14).

3 Likes

That would be awesome!

Thank you!

[edit] oops, nevermind, I made a mistake elsewhere. The code below will work in combination with your solution :smiley:

Thank you!!


That does seem to be a good workaround. Though I’m having some problems converting Autodesk.DesignScript.Geometry.Geometry to the correct curve types.

After checking the curve type I would do something like:

Autodesk.DesignScript.Geometry.NurbsCurve nurbs = Autodesk.DesignScript.Geometry.NurbsCurve)Convert.ChangeType(CurveItem, typeof(Autodesk.DesignScript.Geometry.NurbsCurve));

But that will not work. I get an error that reads “Object must implement IConvertible”.

Do you know how to convert this?

The type returned from Edge.CurveGeometry is a Curve type and cannot be cast (or converted) to any other derived Curve type such as NurbsCurve, at least not before the fix.

However, @c.poupin is right in suggesting the alternative for now as the Explode method does make that conversion internally.

2 Likes