Explode vs Duplicate Segments

Hello fellow grasshoppers,

I have an issue trying to extract curve segments, similar to how “explode” works on rhino, through C#.

For context, a previous investigation led me to use the following method:


But, as you can see on the following example. The result don’t correspond with the fully exploded curve for certain polygons.

If you guys want the definition, here it is, it’s a really simple setup.
Explode_vs_DuplicateSegments.gh (6.0 KB)

I guess what I’m asking, to be concrete, is for either insight for why this is happening (the difference between “explode” and “duplicatesegments”) or for a method withing c# that can generate a more accurate depiction of the segments contained withing a curve.

Thanks in advance, this will really help me a lot to standardize curve geometries.

Hey @Frusciante ,

Great question, I can see how this might be confusing. In Rhino as you can imagine there are A LOT of curves, curve types and curve scenarios. Nurbs, Polyline, PolyCurve etc.

Here, RhinoCommon does the most technically correct thing, and in this case simply breaks the curve up into the pieces available, respecting each original part…

You’re starting off with a polycurve, which is a curve made up of other curves. And it turns out your curve has 3 curves, and so RhinoCommon returns those. The more complex curve which looks to the human eye like 2 lines and an arc, is actually a NurbsCurve. Technically this is one curve so RhinoCommon returns it as is.

Grasshopper generally does a lot more to give you, the user, what you’d expect, so it does a little magic to really break down every type of curve into the simplest possible pieces.

To achieve the same as the Grasshopper component currently, you’d need to recursively move through every curve and handle breaking them down. i.e in your case, you could break up the NurbsCurve into multiple pieces.

– cs

1 Like

GH’s Explode component produces results based on the curve’s geometry. NURBS curves, for example, are split at C1 discontinuities.

RhinoCommon’s Curve.DuplicateSegments method, on the other hand, produces results based on the curve’s data structure.

– Dale


RH-81979 Expose RhinoGetSubCurves to RhinoCommon is fixed in Rhino 8 Service Release 8 Release Candidate 1.

1 Like