How to Get SubDFace

Hi, i am not able to identify the SubD face from a point like in the shot . Anyone? I tried several algorithms but without success

I also have problems iterating for each face to derive the nurbs from its edges. it only makes a few ,so any algorithms become complicated.
Rhino.Geometry.Curve edgeCurveClamp = edge.ToNurbsCurve(true); sometimes null
Rhino.Geometry.Curve edgeCurveNoClamp = edge.ToNurbsCurve(false); sometimes null
Rhino.Geometry.Curve edgeControlNetLine is not usefull

Hi @gianfranco74, below seems to work for simple cases:

import Rhino
import rhinoscriptsyntax as rs

def DoSomething():
    subd_id = rs.GetObject("SubD object", rs.filter.subd, True, False)
    if not subd_id: return
    point = rs.GetPoint("Point near subd")
    if not point: return
    subd_obj = rs.coercerhinoobject(subd_id, True, True)
    brep = subd_obj.Geometry.ToBrep()
    rc, cp, ci, s, t, v = brep.ClosestPoint(point, maximumDistance=100.0)
    if not rc: return
    if ci.ComponentIndexType == Rhino.Geometry.ComponentIndexType.BrepFace:
        index_type = Rhino.Geometry.ComponentIndexType.SubdFace
        component_index = Rhino.Geometry.ComponentIndex(index_type, ci.Index+1)
        subd_obj.SelectSubObject(component_index, True, True, True)


but i’ve seen that it fails if some subd faces have been deleted.

@pierrec, can this be done using SubD.ComponentFromComponentIndex somehow if the brep and subd faces are out of sync ?


1 Like

Hi all, i don’t know what happened, but now i have edges and center of subd face. i can try my algorithms. probably something wrong with my pc or my brain. it is very strange. i will write solution as soon as possible