How to select surfaces in polysurface

I tried selecting surfaces in polysurface but they return array not list. How do they return a list object?

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino
filter = Rhino.DocObjects.ObjectType.Surface
rc, obj_id = Rhino.Input.RhinoGet.GetMultipleObjects("Select first set of polysurfaces", False, filter)
print type(obj_id)

getsurfaces.3dm (187.6 KB)

Usually you can cast the C# type array to a Python list:

print type(list(obj_id))

i am looking for a solution to get list return objects. With the above method we only cast the data type.

Hi @xiix.xoox,

The simple “getters” like RhinoGet.GetMultipleObjects don’t allow for subobject selection. So you’ll need to use a GetObject object instead. Just set GetObject.SubObjectSelect to true.

– Dale

I try to change algorithm to get surfaces object but can’t select surfaces in polysurface ( The value input).

import Rhino
import scriptcontext

def GetSubObject():
    go = Rhino.Input.Custom.GetObject()
    go.SetCommandPrompt("Select objects")
    go.SubObjectSelect = True
    go.GetMultiple(1, 0)
    if go.CommandResult()!=Rhino.Commands.Result.Success:
        return go.CommandResult()
    ids = [go.Object(i).ObjectId for i in range(go.ObjectCount)]
    print ids
if __name__ == "__main__":
    GetSubObject()

Hi @xiix.xoox,

How about this?

import Rhino
import scriptcontext

def test_get_brep_face():
    go = Rhino.Input.Custom.GetObject()
    go.SetCommandPrompt("Select surfaces")
    go.GeometryFilter = Rhino.DocObjects.ObjectType.Surface
    go.SubObjectSelect = True
    go.GetMultiple(1, 0)
    if go.CommandResult()!= Rhino.Commands.Result.Success:
        return
        
    for objref in go.Objects():
        print(objref.ObjectId)
        print(objref.GeometryComponentIndex.ComponentIndexType)
        print(objref.GeometryComponentIndex.Index)

if __name__ == "__main__":
    test_get_brep_face()

– Dale

2 Likes

Thank you so much

A post was split to a new topic: GhPython and Breps