Object id surface and obj


#1

Hi
The attached Python script extract a surface from a polysurface.
It’s possible get also the id of the object without another pick?
Ciao Vittorio

import Rhino
import scriptcontext
import rhinoscriptsyntax as rs

def ExtractSrf(str):    
    
    rs.UnselectAllObjects()
    rc,surfaceref=Rhino.Input.RhinoGet.GetOneObject(str,False, Rhino.DocObjects.ObjectType.Surface  )
    if rc!=Rhino.Commands.Result.Success: return 
    rs.MessageBox(surfaceref)
    sup = surfaceref.Face()
    if sup:
        brep=sup.DuplicateFace(True)        
        superficie=scriptcontext.doc.Objects.AddBrep(brep)
        
        scriptcontext.doc.Views.Redraw()
        return  superficie
if __name__=='__main__':
    sup=ExtractSrf("seleziona superficie da estrarre")

(Steve Baer) #2

AddBrep returns the id of the new object so you should already have it in your ‘superficie’ variable


#3

Hi Steve
Maybe I explained badly: I also want the id of the starting object like in the attached file.
Ciao Vittorio

Extract_Surface.3dm(21.3 KB)


#4

Hi Steve
I solved the problem with idobj=surfaceref.Object()
Thanks for your help.
Ciao Vittorio