ExtractSrf into different name surfaces

When I have a cube and I extract the 6 surfaces, all surfaces have the same name as the original object. Each surface has an ID which a 30 character long name including letters and numbers. Next to the ID there is a number in parantheses. The number increments by one which each face but I can not select by that number. I want to have a script select each surface and do operations on it. Is there a way to do it?

Hi @Nikolaos_Beratlis,

the number in parenthesis is nothing to be used in scripting. The object ID can be used to access an object which is in the document. You won’t need to name your objects to select them. Below a simple example to explode a polysurface and then select / unselect each surface:

import rhinoscriptsyntax as rs

def DoSomething():
    
    # get a polysurface
    brep_id = rs.GetObject("Select Polysurface", rs.filter.polysurface, True, False)
    if not brep_id: return
    
    # explode polysurface in surfaces
    surface_ids = rs.ExplodePolysurfaces(brep_id, delete_input=True)
    if not surface_ids: return
    
    # do something with each surface (select and unselect each)
    for srf_id in surface_ids:
        rs.SelectObject(srf_id)
        rs.Sleep(500)
        rs.UnselectObject(srf_id)
        
if __name__=="__main__":
    DoSomething()

PS. I added rs.Sleep(500) between select / unselect, so you can actully see what happens.
_
c.

Exploding makes the faces into separate surfaces and giving them unique GUIDs. I think original post wants to manipulate without exploding, through scripts. Would this be possible? Like the grasshopper “deconstruct brep”.

Hi @Will_Wang, in order to select each surface individually, exploding is required in Rhino 5.

Yes, see the initial script posted here which goes through the brep faces without exploding it.

_
c.

1 Like