Select creased edge loop programmatically?

I have a subD object with a creased edge loop (two actually). I can select this easily in Rhino with the seledgeloop command and manually picking the edge loop that is creased. But I’m trying to figure out how to do this programatically with Rhinocommon. My thought is to search through all vertices looking to see if the tag status is crease and then interpolate all that are creased and within a threshold distance into a curve (my extracted edge loop doesn’t have to be an exact match, just close).

Or maybe someone here knows a better way?

Thank you,
Sam

Hi @samlochner,

while searching for a way to set creased SubD edges to smooth, i found your question on how to select creased SubD edges. Below seems to work:

#! python 2

import Rhino
import scriptcontext
import rhinoscriptsyntax as rs

def SelectCreasedSubDEdges():
    
    subd_id = rs.GetObject("Select SubD", rs.filter.subd, True, False)
    if not subd_id: return
    
    subd_obj = rs.coercerhinoobject(subd_id, True, True)
    index_type = Rhino.Geometry.ComponentIndexType.SubdEdge
    
    for e in subd_obj.Geometry.Edges.GetEnumerator():
        if e.Tag == Rhino.Geometry.SubDEdgeTag.Crease:
            component_index = Rhino.Geometry.ComponentIndex(index_type, e.Id)
            subd_obj.SelectSubObject(component_index, True, True, True)
    
SelectCreasedSubDEdges()

thanks,
c.

1 Like

Thanks Clement!