Modo Material Tags and Selections (Python)

modo

#1

Aloha, maybe someone in this Forum give me a few hints for Modo scripting.
I started Scripting in Modo recently and Im not completly sure how to work in a right way with materials.
Im unsure how exactly material tags, material masks, and items are connected to each other.

If i have a list of material tags in the scene like:

scene = modo.Scene()

 materials = set()

for mesh in scene.iterItems(lx.symbol.sITYPE_MESH):
    geo = mesh.geometry
for x in xrange(geo.PTagCount(lx.symbol.i_PTAG_MATR)):
        materials.add(geo.PTagByIndex(lx.symbol.i_PTAG_MATR, x))

materials = list(materials)

How is it possible to get the connected Items (at which the mats are apllied)??

if len(elm) <= len(obg):
	print "1 Mat changed to " + elm + " from " + obg	
	print scene.selected
	
	#modo.scene.selected = modo.Mesh("bla").channels (Bsp von items) 
	#modo.Mesh(name).
	#for elements in scene.selected:
	#	if elements. : 	
	lx.eval('poly.setMaterial %s' %  elm) #sets the material

Any Help would be appreciated.
Greetings Goofy GUber