Skip to content

Instantly share code, notes, and snippets.

@tokejepsen
Created August 15, 2013 14:59
Show Gist options
  • Save tokejepsen/6241531 to your computer and use it in GitHub Desktop.
Save tokejepsen/6241531 to your computer and use it in GitHub Desktop.
converts bip files to fbx
import os
import subprocess
def convertBipToFbx(mainDir):
#collecting bip files
bipFiles=[]
for r,d,f in os.walk(mainDir):
for files in f:
if files.endswith(".bip"):
bipFiles.append(os.path.join(r,files))
for bip in bipFiles:
count=bipFiles.index(bip)
print 'Doing %s: %s of %s' % (bip,count+1,len(bipFiles))
#setting input and output
inputDir=bip
outputDir=bip.replace('.bip','.fbx')
#generate command
cmd='"C:/Program Files/Autodesk/3ds Max 2014/3dsmax.exe"'
cmd+=' -mxs "frameRate=25;animationRange = interval -10 1000;bipObj = biped.createNew 100 -90 [0,0,0];'
cmd+='sliderTime = -10;'
cmd+='bip = bipObj.controller;biped.loadBipFile bip \\"%s\\";' % inputDir
cmd+='biped.loadCopyPasteFile bip \\"M:/00719_grandpa/assets/Animation/ros_bips/tpose.cpy\\";'
cmd+='with animate on(;'
cmd+='biped.pastePosture bip #posture True \\"HorVerRotPlvsSpnLArmRArmLFingRFingLLegRLegLToeRToeHd01\\";'
cmd+='obj=$Bip001;'
cmd+='biped.setTransform obj #rotation ((eulerAngles 0 0 -90) as quat) True;'
cmd+='biped.setTransform obj #pos [0,0,54] True);'
cmd+='bip = $Bip001.transform.controller;'
cmd+='vertCont = bip.vertical.controller;'
cmd+='k = vertCont.keys;last_frame=-10f;if(k.count > 0) do(;'
cmd+='t = k[k.count].time;if(t > last_frame) do last_frame = t);'
cmd+='animationRange = interval -10 last_frame;'
cmd+='exportFile \\"%s\\" #noPrompt"' % outputDir
#execute command
subprocess.call(cmd)
convertBipToFbx('M:/00719_grandpa/assets/Animation/ros_bips/Bips')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment