Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® MotionBuilder® / Python / Save without takes
  RSS 2.0 ATOM  

Save without takes
Rate this thread
 
30688
 
Permlink of this thread  
avatar
  • pmsimard
  • Posted: 08 June 2009 09:29 AM
  • Location: Montreal
  • Total Posts: 34
  • Joined: 27 August 2006 02:28 PM

Version: MB2009

I i’m trying to save the scene without saving the takes and i can’t seems to set FBFbxManager().Takes like if it was read-only.

any idea how to do this?

Thanks



Replies: 0
avatar

There is a really great sample that comes with MotionBuilder called ‘SaveOneTakePerFile’, which from you description is exactly what your trying to do. Since takes are embedded in MotionBuilder you have to at least have one take per file.

In the class FBFbxManager, the UI functionality File > Save Selected > Save One Take Per File does not exist here, but you can achieve the same end by stepping through the takes in the scene and setting their attributes individually.

rom pyfbsdk import FBSystemFBApplicationFBFbxManager

# First get some needed objects.
lSystem      FBSystem()
lApplication 
FBApplication()
lFileName    
lApplication.FBXFileName

# We want to make sure that we have a scene with file name
# already, otherwise we might want to open a file popup.
# For now we assume that there is already a name to use as a
# base name.
if lFileName.upper().endswith( '.FBX' ):

    
lMgr FBFbxManager()
    
    
# Since we will need to change the current take as we
    # save them, we keep the orginal take around to reset
    # it afterwards.
    
lOriginalTake lSystem.CurrentTake

    
# Iterate the list of takes.
    
for lTake in lSystem.Takes:
    
        
# Switch the current take to the one we want to save.
        
lSystem.CurrentTake lTake
        
        
# Build the file name to use. Here we use the same pattern
        # MotionBuilder would use.
        
lTakeFileName "%s-%s.fbx" ( lFileName[:-4]lTake.Name )
        
        
# Some feedback for the user...
        
print "Saving Take '%s' to file '%s'" ( lTake.NamelTakeFileName )

        
# Go through the actual process of saving to the file.
        # WARNING: We do not do any error checking on the return
        #          values of SaveBegin()/Save()/SaveEnd()!!!
        
lMgr.SaveBegin( lTakeFileName )

        
# Let's save to ASCII format.
        
lMgr.UseASCIIFormat True

        
# Go through the list of takes to export to tag only
        # the correct take. All the other are disregarded.
        
for lTakeSave in lMgr.Takes:
            if 
lTakeSave.Name != lTake.Name:
                
lTakeSave.Import False
            
            
# Cleanup
            
del( lTakeSave )

        lMgr
.Save()
        lMgr
.SaveEnd()
        
        
# Cleanup.
        
del( lTakelTakeFileName )

    
# Return the current take to the original.
    
lSystem.CurrentTake lOriginalTake
    
    del( lMgr
lOriginalTake )

else:

    print 
'File name does not end with ".fbx". Unable to proceed!'


# Cleanup of local variables.
del( lSystemlApplicationlFileName )

# Cleanup of imported symbols.
del( FBSystemFBApplicationFBFbxManager )


KRISTINE MIDDLEMISS | SENIOR DEVELOPER CONSULTANT
AUTODESK DEVELOPER NETWORK Media & Entertainment
http://www.autodesk.com/joinadn

Replies: 0
avatar
  • pmsimard
  • Posted: 15 September 2009 03:01 AM

Thanks Kristine.



Replies: 0