Page 1 of 1

Accessing mesh users ?

Posted: Tue May 08, 2007 5:02 pm
by u3dreal
Hi all,

since this is my first post i'd like to say hello to everybody. ;)

Hello !!!!

I'm about to help Ian with the blender exporter for
radium ( ). So he can concentrate on the core.

Radium is a very exciting renderer using MLT to get excellent photrealistic
Images. Since i fell in love with blender not long ago
it was an ease to fall in love with Radium.

Ok so here my question.

During implementing instancing i found some unclear
part that i couldn't find anything on the net.

Is it possible to get the following data from the Blender.Mesh obj.
I would like to know the names of all users (objects) of the mesh.
I found that i could read out the total number of users by
Blender.Mesh.users but i couldn't find anything on how
to get the names of the users.

Any help would be apprechiated.


u3dreal ;)

Posted: Wed May 09, 2007 3:11 pm
by reD_Fox
Boy, this may not be the right answer, but it's the only way I can think to do it:

Loop through all objects, comparing ob.getData(name_only=True) to the mesh's name.

I don't think the mesh is even aware of who all has its data (but I could be wrong).


Posted: Wed May 09, 2007 5:48 pm
by revans
I believe reD_Fox is correct. Here's a function that I wrote that may suit your needs:

Code: Select all

def getUsers(mesh):
  toReturn = []
  scene = Scene.GetCurrent()
  meshes = filter(lambda x: x.getType() == "Mesh", scene.getChildren())
  for mesh_obj in meshes:
     if mesh_obj.getData(False, True).name ==
  return toReturn
Hope this helps!

Posted: Wed May 09, 2007 6:15 pm
by revans
Or, if you prefer list comprehensions:

Code: Select all

def getUsers(mesh):
  scene = Scene.GetCurrent()
  meshes = [obj for obj in scene.getChildren() if obj.getType() == "Mesh"]
  return [mesh_obj.getName() for mesh_obj in meshes if mesh_obj.getData(False, True).name ==]

Posted: Thu May 10, 2007 4:14 am
by reD_Fox
Yes, revans got it right, with one small exception:
should be changed to
for performance reasons.
The former loads the mesh into memory, then gets its name, when all you need is the mesh's name.