Message 1 of 2
Batch Scripts For Processing Multiple Files
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I've tried two options:
1) motionbuilder.exe -console current -batch -verbosePython cli.py
and
2) mobupy.exe cli.py
for my cli.py script - it's a simple script that prints out the takes in an fbx file after opening it.
At our studio we do a lot of batch processing inside mobu after it's opened. I'd prefer to be able to batch process these files without opening Mobu so we can make this more automated.
As far as I know i'm following how this should be done according to the docs, but i'd like to know if anyone knows how to run batch processes in mobu correctly from the commandline?
Here's my code for the file and this works inside mobu:
import sys
import pyfbsdk
import os
def main(file_path):
# if len(sys.argv) < 2:
# print("No FBX files provided.")
# return
# Get the list of FBX files from command-line arguments
fbx_folder = file_path
fbx_files = []
for root, dirs, files in os.walk(fbx_folder):
for file in files:
if file.endswith(".fbx"):
fbx_files.append(os.path.join(root, file))
# limit the number of files to process to 2
fbx_files = fbx_files[:2]
for file_path in fbx_files:
try:
# Open the FBX file
pyfbsdk.FBApplication().FileOpen(file_path)
print(f"\nOpened FBX file: {file_path}")
# Get the list of takes in the file
take_manager = pyfbsdk.FBSystem().Scene.Takes
if take_manager:
print("Takes in the file:")
for take in take_manager:
print(f"- {take.Name}")
else:
print("No takes found in the file.")
except Exception as e:
print(f"Failed to process {file_path}: {e}")
if __name__ == "__main__":
file_path = r"T:\aresbb\capture\aresbb01\retarget\3_approved_anim\shot prep\mobu_cleanup_processed"
print("Folder:", file_path)
main(file_path)