Rhino explodes curve but not grasshopper

crv.3dm (142.9 KB)

can anyone explode this in grasshopper?

noexplode

Hi @Will_Wang ,

This one has me stumped… but I did manage to “Explode” it by exploiting the extrude component.

See Below:

Graph Space:

Model Space:

20230819_Explode_Nurbs_Curve_Not_Accepting_Explode_Commands_Response_01a.gh (17.6 KB)

it’s an option. but i hesitate to do this if i have hundreds of these. lots of added computation…

It doesn’t explode with the new ‘Explode Objects’ component in the R8 WIP Grasshopper either.

1 Like

Of course, hence why I put explode in quotes haha. I couldn’t get it to explode in R8 or in Python with scripting.

Perhaps using a scripting component in GH to duplicate, temporarily explode it in Rhino, reference the exploded bits into sticky in the script and then removing the temporarily exploded curve could work.

But again seems like too much extra work for what should be a single command.

Hopefully someone has the simple answer

I came across this yesterday regarding a different issue. Possibly related depending on how the grasshopper component is implemented?

rs.ExplodeCurves has different behavior than Explode Rhino command? - Scripting - McNeel Forum

Thanks @Nathan_Bossett ,

That helped guide me and I got a successful Python implementation working.

@Will_Wang Try this out and let me know if it works for your purposes:

Graph Space:

Model Space:

Python:

__author__ = "Michael Vollrath"
__version__ = "2023.08.19"
#Made With <3 In Dallas, TX

ghenv.Component.Name = "Get Sub Curves"
ghenv.Component.NickName = "GSC"
ghenv.Component.Description = "Retrieve the sub curves that make up a joined, referenced curve"

ghenv.Component.Params.Input[0].Name ="Curve"
ghenv.Component.Params.Input[0].NickName ="C"
ghenv.Component.Params.Input[0].Description ="Curve To Explode"

ghenv.Component.Params.Output[0].Name ="Exploded Curves"
ghenv.Component.Params.Output[0].NickName ="Ex"
ghenv.Component.Params.Output[0].Description ="Exploded Curves"

import Rhino
import scriptcontext as sc
import rhinoscriptsyntax as rs

#Set The Script Context To The Rhino Doc
sc.doc = Rhino.RhinoDoc.ActiveDoc

Ex = []

def explode_referenced_curve():
    # Get The Rhino Object From The GH Input
    rh_obj = rs.coercerhinoobject(C)
    if not rh_obj:
        return

    # Get The Sub Objects
    sub_objs = rh_obj.GetSubObjects()
    if not sub_objs:
        return

    # Add Sub Curves To List Of All Sub Curves
    for obj in sub_objs:
        Ex.append(obj.Geometry)

    #Show Component Message
    ghenv.Component.Message = str(len(Ex)) + " Curves Found"

    return C


if __name__ == "__main__":
    explode_referenced_curve()

#Set The Script Context Back To Grasshopper
sc.doc = ghdoc

20230819_Explode_Nurbs_Curve_Not_Accepting_Explode_Commands_Response_01b.gh (14.1 KB)

2 Likes

Hi Will - for now, Explode the curve in Rhino, SimplifyCrv the results then Join and GH likes ity OK.

-Pascal

i baked it from GH. it was a result of a intersection between a Plane and a Brep. just to show the problem. hopefully there’s a fix at some point so i don’t have to bake(bait) and switch. thanks

Can you share this portion of it? It may be an issue with the way the brep was constructed inititially

i did reconstruct the Brep differently to work around this problem
i do think this curve can be nevertheless investigated in isolation
the difference between rhino explode and the gh component seems like a bug to me

as far as i read in other topics:

grasshopper explode gives back sub-objects / segments of a Polycurve
rhino explode splits at Discontinuity
It also seams a difference wether you handle Segments vs. SubObjects.

as the given Curve is a single Nurbs Curve… (has no Sub-Objects / Segments…)

so my solution is using Discontinuity:

explode_Curve_00.gh (8.7 KB)

with this script:

List<double> ts = new List<double>();
double t0 = crv.Domain.T0;
double t1 = crv.Domain.T1;
// handle closed curves
// not sure if this is the best / correct way...
if (crv.IsClosed)
{
    ts.Add(t0);
}
// collect all Discontinuities
// also see
// https://discourse.mcneel.com/t/rhinocommon-equivalent-of-explode/21093/8
double tLast = t0;
double ti = t0;
while (crv.GetNextDiscontinuity(Continuity.Gsmooth_continuous, tLast, t1, out ti)) {
    ts.Add(ti);
    tLast = ti;
}

Curve[] crvs = crv.Split(ts);
if ((crvs != null) && (crvs.Length > 1))
{
    A = crvs;
} else
{
    Print("split failed");
    A = crv;
}

It seams that it also makes a difference wether

hope this helps - kind regards -tom

4 Likes

c2 continuity was able to detect the inflections/break points
thanks