Finding all 'tags' of a loaded model?

Hi, is there any way to list all tags of a model made in blender?

for instance:

map.egg has:
    Cube
        tag: 'mytag'
    Plane
        tag: 'myplane'
    Cube
        tag: 'my zone'
    Sphere

I need to find all the sub nodes of map.egg that have tags, however I also need to ignore the sub nodes without tags?

This is how I am currently doing it:

from direct.directbase import DirectStart

def getInfo(node):
	for subNode in node.getChildren():
		print subNode

model = loader.loadModel('m1.egg')
getInfo(model)

now this prints ‘m1.egg/-PandaNode’

I know for a fact that the subnodes are in it, because this works:

from direct.directbase import DirectStart

def getInfo(node):
	for subNode in node.getChildren():
            for realSubNode in subNode.getChildren():
                print realSubNode

model = loader.loadModel('m1.egg')
getInfo(model)

prints the following:

m1.egg/-PandaNode/Cube
m1.egg/-PandaNode/start
m1.egg/-PandaNode/collide
m1.egg/-PandaNode/zone3
m1.egg/-PandaNode/zone2
m1.egg/-PandaNode/zone1

My question is, why is the -PandaNode even there? instead of returning the direct children of m1.egg?

What’s it use? and is there a better way to do this?

Just FYI, there’s often an easier way using NodePath.find:

nps = model.findAllMatches("**/=mytag")

That will return a collection of all NodePaths that have the “mytag” tag key.

More info:
panda3d.org/apiref.php?page=NodePath

Hi, thank you much for pointing me to that! That is just what I needed.

It works great.

Code for anyone else:

for np in mymodel.findAllMatches('**/=mytag'):
    print "%s has tag %s!" % (np, tag)

again, thank you very much!