# Find polysurface guid from sub-surface selection?

**URL:** <https://discourse.mcneel.com/t/find-polysurface-guid-from-sub-surface-selection/28844>\
**Category:** Scripting\
**Created:** [January 29, 2016, 11:13pm UTC](https://discourse.mcneel.com/t/find-polysurface-guid-from-sub-surface-selection/28844 "2016-01-29T23:13:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![egradman](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/egradman/32/235358_2.png) [@egradman](https://discourse.mcneel.com/u/egradman)\
**Post date:** [January 29, 2016, 11:13pm UTC](https://discourse.mcneel.com/t/find-polysurface-guid-from-sub-surface-selection/28844/1 "2016-01-29T23:13:31Z")

</div>

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
```

---

<div class="post-metadata">

**Author:** ![clement](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/clement/32/759176_2.png) [@clement](https://discourse.mcneel.com/u/clement)\
**Post date:** [January 29, 2016, 11:22pm UTC](https://discourse.mcneel.com/t/find-polysurface-guid-from-sub-surface-selection/28844/2 "2016-01-29T23:22:18Z")

</div>

@egradman,

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

```python
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.

---

<div class="post-metadata">

**Author:** ![egradman](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/egradman/32/235358_2.png) [@egradman](https://discourse.mcneel.com/u/egradman)\
**Post date:** [January 30, 2016, 4:36pm UTC](https://discourse.mcneel.com/t/find-polysurface-guid-from-sub-surface-selection/28844/3 "2016-01-30T16:36:16Z")

</div>

> [@clement](#):
>
> print “ObjectId:”, objref.ObjectId

Perfect!
