Motionbuilder: retrieve a model's texture

Getting my hands dirty with Motionbuilder and its python at the moment, but having some difficulties and hopefully some of you know the answer to my question :).

What I want to do is to retrieve the texture thats a assigned to a certain model with python.

And since i’m still kinda new to python and stuck in a maya-python mode :frowning: I’m having troubles adapting to Motionbuilder-python.

Any help would be appreciated, thanks!

It’s kind of a pain since I am not aware of any direct way to retrieve a texture name from a model, but you can trace the connections to find “FBVideoClip” nodes (which are the actual texture files, not the FBTexture node).


from pyfbsdk import *

# Select some models
lModelList = FBModelList()
FBGetSelectedModels(lModelList)

for lModel in lModelList:
   lTextures = []
   # First find FBTexture nodes connected to the model
   for i in range(lModel.GetSrcCount()):
      lConnection = lModel.GetSrc(i)

      if lConnection.ClassName() == 'FBTexture':
         lTextures.append( lConnection )

   for t in lTextures:
      # Now find FBVideoClip nodes connected to each texture
      for j in range(t.GetSrcCount()):
         lConnection = t.GetSrc(j)
   
         if lConnection.ClassName() == 'FBVideoClip':
            # Do something with the Filename
            print lConnection.Filename


If someone knows an easier way please fill us in.

Stev

gonna try it out thanks!
that solution could be good for me beacuse i also want to get hold of other things connected to the FBmodels :slight_smile:

it’s too bad that the community around the mobu python isn’t that big, hard to find good info about it. perhaps something for us to change?