RhinoCommon: GetObjectList and NameFilter


#1

Hi,

I am using GetObjectList to collect Rhino Objects with ObjectEnumeratorSettings.
I need to collect objects with few names.
Currently I am using NameFilter property for passing one name I am looking for.
That means the following: if i have 10 names to look - I need to run GetObjectList 10 times.

Is it possible to add option to use array of names for NameFilter property, so that GetObjectList is executed only once?

Thanks,
Dmitriy


#6

That would be nice, also to use an array of layer indices. To look up multiple names i used this as a replacement, it requires only 1 run of GetObjectList:

import Rhino
import scriptcontext

def FindObjectsByNames(search_names):
    settings = Rhino.DocObjects.ObjectEnumeratorSettings()
    settings.HiddenObjects = False
    settings.DeletedObjects = False
    
    rc = []
    for obj in scriptcontext.doc.Objects.GetObjectList(settings):
        if obj.Name in search_names:
            rc.append(obj)
    return rc

if __name__ == "__main__":
    search_names = ["A","B","C"]
    rc = FindObjectsByNames(search_names)
    print "Found", len(rc), "objects"

note that it is a case sensitive search by names.
_
c.