Exploding RhinoCommon HiddenLineDrawing segments

So once I have computed my HiddenLineDrawing, I have a collection of segments which are stored in .Segments…

    hdp=Rhino.Geometry.HiddenLineDrawingParameters()
    hdp.AbsoluteTolerance=sc.doc.ModelAbsoluteTolerance
    [hdp.AddGeometry(sc.doc.Objects.Find(objID).Geometry,"") for objID in objIDs]
    hdp.SetViewport(vp)
    hdp.Flatten=True
    hld=Rhino.Geometry.HiddenLineDrawing.Compute(hdp,True)
    
    #enumerate the collection of segments
    for i,seg in enumerate(hld.Segments):
        #this works
        crvID=sc.doc.Objects.AddCurve(seg.CurveGeometry)

However, some segments are polycurves I would like to explode… And I haven’t figured out how to turn the “HiddenLineDrawingSegment+HldCurveProxy” into RhinoCommon curve geometry so that I can explode it…

All I have been able to do so far is add the unexploded curve to the document as my scriptlet example above, and then explode it with rhinoscriptsyntax methods… which I would like to avoid if possible. I assume there has to be something simple I missed for doing this?

Edit: BTW, after compute, I can get hld.Segments - that is the only thing that seems to work though - I cannot seem to access hld.Objects or hld.FullCurves as it seems I should…

Thanks,
–Mitch

Try doing this:

crv = seg.CurveGeometry.DuplicateCurve()

and then explode crv.

You can get the 'full" parent curve like this:

parent_curve  seg.ParentCurve

– Dale

Thanks @dale! One other quick question- I know the native Make2D command can also preserve original object attributes such as layer, color. I was wondering if any of this is exposed in RhinoCommon? I see there is a “tag” we can add to the input objects, but I don’t see how that gets transferred to the result (if it does)…

Thx, --Mitch

Yes, use the tag parameter HiddenLineDrawingParameters.AddGeometry.

You can retrieve the tag from the full curve.
Given hld_curve is a HiddenLineDrawingSegment object:

fullcurve_source = hld_curve.ParentCurve.SourceObject
tag = fullcurve_source.Tag

– Dale

1 Like

OK, that’s working, thanks again Dale! --Mitch