Select objects by key/value
_
i’m writing a little script in python to manage user string.
-i want to create a selection list box of key/value:
example:
first listbox: all the keys of the active doc
----------listBox-------------
select on key:
“material”
“zone”
“type”
----------------ok-----------------
after clicking on the key: “material”, the items of the listbox will be all the values related to that key (eg. “material”)
--------listBox------------
select values of “material”:
-any-
“steel”
“glass”
“wood”
------------ok-------------
clicking by clicking the objects will be selected until i will click the buttom “ok” going back to keys in order to select others key/values or clicking again “ok” in order to get that selection.
i need some commands i cannot find:
getkeys list of the active document
getvalues list related to a key
some body knows those commands?
an other question:
why i cannot iterate this:
objsId = rh.RhinoDoc.ActiveDoc.Objects.GetObjectList(rh.DocObjects.ObjectType.AnyObject)
this doesn’t give me a list but an 'EnumeratorWrapper’
do you have some suggestion?
keys.append(k)
values.append([value])
kList = rs.ListBox(keys, "Keys to select:", "Select Objs by Key/Value")
if kList in keys:
index_kList = keys.index(kList)
vList = rs.ListBox(["all"] + values[index_kList], "Values of " + kList , "Select Objs by Key/Value")
if vList == "all":
vList = "*"
if vList:
objs = rh.RhinoDoc.ActiveDoc.Objects.FindByUserString(kList, vList, True, True, True, rh.DocObjects.ObjectType.AnyObject)
rs.SelectObjects(objs)