rs.ExplodeCurves has different behavior than Explode Rhino command?

Hi @Hunter2,

The difference is that the underlying function behind rs.ExplodeCurves is Curve.DuplicateSegments, and the Explode command uses RhinoObject.GetSubObjects.

Here is a more equivalent script:

import Rhino
import scriptcontext as sc

def test_explode_curve():
    # Pick a single curve object
    filter = Rhino.DocObjects.ObjectType.Curve
    rc, objref = Rhino.Input.RhinoGet.GetOneObject("Select curve to explode", False, filter)
    if not objref or rc != Rhino.Commands.Result.Success: 
        return
    
    # Get the selected Rhino object
    rh_obj = objref.Object()
    if not rh_obj:
        return
    
    # Get the sub0objects
    sub_objs = rh_obj.GetSubObjects()
    if not sub_objs:
        return
    
    # Add the sub-object geometry
    for sub_obj in sub_objs:
        sc.doc.Objects.Add(sub_obj.Geometry)
    sc.doc.Objects.Delete(rh_obj)
    sc.doc.Views.Redraw();

if __name__ == "__main__":
    test_explode_curve()

– Dale

1 Like