ObjRef.Brep() modifies objref of InstanceObject

I just discovered that ObjRef.Face() returns None after a call to ObjRef.Brep() when the objref references an InstanceObject (ComponentIndexType is BrepFace). This occurs in Rhino 7.21 and 6.

from __future__ import print_function
import Rhino

def main():
    
    rc, objref = Rhino.Input.RhinoGet.GetOneObject(
        "Select face in block",
        acceptNothing=False,
        filter=Rhino.DocObjects.ObjectType.Surface)
    if rc != Rhino.Commands.Result.Success: return
    
    print(objref.Face())
    print(objref.Brep())
    print(objref.Face())

if __name__ == '__main__': main()
<Rhino.Geometry.BrepFace object at 0x00000000000000C3 [Rhino.Geometry.BrepFace]>
<Rhino.Geometry.Brep object at 0x00000000000000C4 [Rhino.Geometry.Brep]>
None

Block_NoBlock.3dm (71.3 KB)

Hi @spb,

Yes, I see this.

When you ask for a Brep, the object reference cooks up a proxy Brep - because you picked an instance object. This null and voids the face once held by the object reference.

If you need the owning Brep, best to get it from the face.

ā€“ Dale

1 Like