RhinoCommon get a Brep edge


#1

Still struggling with Rhino.Input.RhinoGet and Rhino.Input.Custom.GetObject… Say I want to get a Brep open edge (in a single face or multiface Brep), and at the same time get the Brep ID that the edge belongs to…AND which face the open edge belongs to… I managed to kludge the first two, although there has to be something more elegant…

Thx, --Mitch

import rhinoscriptsyntax as rs
import Rhino
import scriptcontext as sc

def TestGetBrepOpenEdge():
    #Get edge
    go = Rhino.Input.Custom.GetObject()
    go.SetCommandPrompt("Pick open edge of brep")
    go.GeometryFilter = Rhino.DocObjects.ObjectType.Curve
    go.GeometryAttributeFilter = Rhino.Input.Custom.GeometryAttributeFilter.EdgeCurve
    rc = go.GetMultiple(1, 1)
    if rc!=Rhino.Input.GetResult.Object: return
    edge = go.Object(0).Edge()
    
    #check to see if edge is open
    if edge.Valence != Rhino.Geometry.EdgeAdjacency.Naked:
        print "Edge is not open" ; return
    else:
        edgeCrv=edge.ToNurbsCurve()
        sc.doc.Objects.AddCurve(edgeCrv)
    #Get brep which belongs to edge and extract geometry
    brepID = go.Object(0).ObjectId
    brep=sc.doc.Objects.Find(brepID).Geometry
    print "Edge belongs to Brep ID {}".format(brepID)
    
TestGetBrepOpenEdge()

(Menno Deij - van Rijswijk) #2

I think that you should be able to do

# the returned curve should be of type BrepEdge if I'm correct
crv = go.Object(0).Curve() 
Brep b = crv.Brep
if b is not None:
    print "Edge is indeed of type BrepEdge"