Why rg.Curve.DuplicateSegments() can't explode this NurbsCurve?

Hello all.
I’m an architect and I’m trying to do a GH plugin for architecture design.
Programing is not in my occupational area so maybe my questions comes out a little bit frequently. I’m sorry for that if any of you think it’s annoying. And REALLY thanks to your patience :grinning:

I don’t understand why the type of the curve in the Rhino file that I uploaded changed from “PolyCurve” into “NurbsCurve” after using rg.Curve.ProjectToPlane.

And another question is that the projected curve can’t use crv.DuplicateSegments to explode it into single piece. As you can see from the printscreen, crvSegments[5] is still a line and an arc join together. I can explode it in Rhino after I bake it out. But I can’t expolde it in ghpython when I using crv.DuplicateSegments. What’s the reason? Or did I use the wrong function to expolde the curve?

DuplicateSegments.3dm (70.9 KB)
DuplicateSegments.gh (6.9 KB)

I would recommend getting familiar with the RhinoCommon API, in this case: the Curve.ProjectToPlane method returns a Curve class instance. The inheritance tree of the different curve types can be a bit confusing to be honest, but keeping the API under one’s pillow always helps me :wink:

This seems to work (at least like how I would expect it to):

DuplicateSegments_AHD.gh (7.4 KB)

Maybe you are misunderstand my question or I didn’t clarified it enough. Anyway thank you AndersDeleuran. I’m trying to clarify these questions again.

It suppose to get 8 segments, but only get 7 segments. You can see, Segs[5] actually can be divided into 2 segments: one line and one arc. And if you bake these segs out into Rhino, the Segs[5] can explode into 2 crvs.

The input curve is combined by several lines and arc, which is PolyCurve type. Actually this curve shouldn’t be deformed in theory after project into new XYplane. Because the two planes are parallel. The curve should only be translate after I using ProjectToPlane.
If I do this projection in Rhino without GHpython, Rhino says it’s an “Arc” type, not the “Nurbs arc”:

But if I do this projection though RhinoCommon , when I bake the Segs[5] out into Rhino, Rhino says it’s a Open NURBS curve, which can explode into 2 crvs( and here comes the second question, why this two segments can’t explode in RhinoCommon? ):

Futher more, if I explode the Segs[5] and get two segments in Rhino, the curved segment’s type is “Nurbs arc”, not “arc” :

I don’t understand why the type changed from “arc” into “nurbs arc” if I use RhinoCommon, and no type change if I use Rhino itself. And I also can’t figure out why the seg[5] can’t expolde in RhinoCommon.

1 Like

You might want to try this:

import scriptcontext as sc
import rhinoscriptsyntax as rs
import Rhino.Geometry as rg

crv1 = rs.coercecurve(x)
crv2 = rg.Curve.ProjectToPlane(crv1, rs.WorldXYPlane())

b = crv3.DuplicateSegments()
print len(crv1.DuplicateSegments()), type(crv1)
print len(crv2.DuplicateSegments()), type(crv2)
print len(crv3.DuplicateSegments()), type(crv3)

c = b[i]

Rhino’s native ProjectToCPlane function probably has simplifying built-in…

HTH, --Mitch

1 Like

Thank you Helvetosaur, that works.:grinning: