Select PolyCurve Segment

Using Python Script. How do I select the an individual segment of a polycurve? rs.SelectObject requires a GUID.

Hi @Mike24,

below selects the first segment of a polycurve. You’ll still need the polycurve’s id though:

import Rhino
import scriptcontext
import rhinoscriptsyntax as rs

def pc_filter(rhino_object, geometry, component_index):
    return isinstance(geometry, Rhino.Geometry.PolyCurve)

def DoSomething():
    crv_id = rs.GetObject("Select a PolyCurve", 4, False, False, pc_filter)
    if not crv_id: return
    
    crv_obj = rs.coercerhinoobject(crv_id, True, True)
    ci = Rhino.Geometry.ComponentIndex(
                            Rhino.Geometry.ComponentIndexType.PolycurveSegment,
                            0
                            )
    
    crv_obj.SelectSubObject(ci, True, True, True)
    scriptcontext.doc.Views.Redraw()
    
DoSomething()

_
c.

1 Like

@clement - Thanks!