[motionbuilder python] change audio clip file path

(totally new to Mobu) Trying to change the file paths on some story audio clips. The clips aren’t present in the scene browser though, because the paths are bad (they’re only visible in the story editor, waiting for the paths to be fixed).

Am I right in the thinking the clips are “gone” from the scene, and their only remnant is the story audio clips that are trying to reference them? The fix is to access the story clips and…

brain overload.

Did this before, this basic snippet maybe useful here. Can be tweaked to work with different clip types such as animation and video.

from __future__ import print_function
from pyfbsdk import FBSystem, FBApplication, FBStory, FBPropertyManager, FBStoryTrackType


def _iterateFolderTracks( folder, callback ):
    
    for track in folder.Tracks:
        callback( track )
        _iterateSubtracks( track, callback )
        
    for child in folder.Childs:
        _iterateFolderTracks( child, callback )


def _iterateSubtracks( track, callback ):
    
    for subTrack in track.SubTracks:
        callback( subTrack )
        _iterateSubtracks( subTrack, callback )
    

def myCallback( track ):
    # Track found
    if track.Type.numerator == FBStoryTrackType.kFBStoryTrackAudio.numerator:
        # This is an audio track
        print( "Audio track:", track.Name )
        for clip in track.Clips:
            print( "Clip:", clip.Name )
            property = clip.PropertyList.Find( "ClipAudioPath" )
            if property:
                oldMediaPath = str( property.Data )
                print( "    Media path:", oldMediaPath )
                # Replace the path:
                # property.Data = newMediaPath


def main():
    
    story = FBStory()
    
    for folder in ( story.RootFolder, story.RootEditFolder ):
        # Find all tracks in story folder, call myCallback for every single find
        _iterateFolderTracks( folder, myCallback )

Wow, thanks so much! This is very helpful! Almost too helpful… :slight_smile:

Is the “.numerator” stuff in the help docs? Some of this stuff makes me think, “How would I ever find that…?!”

Thanks again!

Glad it help.

I only have somewhat limited experiences with MoBu Python scripting myself, but here is what I consider as realistic expectation for information sources:
10% from documentation & examples
10% from Googling
80% from hand coded introspection

:slight_smile:

I’m still fighting that truth!!!