Search many objects within the scene.


This is more a python than a Panda related question.
Suppose that I’m having N trees and I would like to add them to my scene using find("/tree1"), find("/tree2)… find("**/treeN").

How can I tell to python find("*//treei") ?
Where, off course, i is starting at 1 and finishing at N.

(Saw it somewhere on this forum but can’t find it anymore…)

Do you mean something like root.findAllMatches(’**/tree*’)? Assuming you haven’t recklessly added something like ‘treebeard’ that you don’t want it to find.


Not really. All my trees objects are empties and I would like to reference all empty with the name “treei” to one egg file and then reposition it to the scene. And after that the same thing with “planti”… etc

Well, then, why not do something like this:

for i in range(N):
  tree = root.find('**/tree%s' % (i))
  .. do stuff with treei ..


Okay, maybe I should explain a little bit more.
I was instancing objects using Chicken and was happy with the result. But I was surprized to see that the instance is not working anymore when transforming to .bam files.

So, now I’ve got to find a new way to instance my .bam files!
Which lead me to that question: "How can I tell to python find("*//treei") ? "

EDIT: thank you David, that is what I was searching for… :slight_smile: