Find polysurface guid from sub-surface selection?

Using Rhino.Common, I can prompt the user to select a sub-surface of a polysurface (which I’m adding to the document for further manipulation). How can I obtain a reference to the polysurface that contains this subsurface?

Here’s my code for sub-surface selection.

import Rhino
import System.Guid
import scriptcontext
import rhinoscriptsyntax as rs

def GetSubSurface(prompt="select subsurface"):
  # get a surface of an object
  go=Rhino.Input.Custom.GetObject()
  go.GeometryFilter=Rhino.DocObjects.ObjectType.Surface
  go.SetCommandPrompt(prompt)
  go.Get()
  print go
  objref = go.Object(0)
  go.Dispose()

  brep = objref.Face().DuplicateFace(True)
  guid = scriptcontext.doc.Objects.AddBrep(brep)

  if (guid != System.Guid.Empty):
    rc = Rhino.Commands.Result.Success
    scriptcontext.doc.Views.Redraw()
  return guid

@egradman,

try below, objref.ObjectId should be used before using go.Dispose()

import Rhino
    
def GetSubSurface(prompt="select subsurface"):
    # get a surface of an object
    go = Rhino.Input.Custom.GetObject()
    go.GeometryFilter = Rhino.DocObjects.ObjectType.Surface
    go.SetCommandPrompt(prompt)
    go.Get()
    objref = go.Object(0)
    print "ObjectId:", objref.ObjectId
    go.Dispose()
    
GetSubSurface()
 

c.

Perfect!