Motionbuilder Python FBFilePopupStyle.kFBFilePopupOpen

Hello,

I’m trying to use FBFilePopupStyle.kFBFilePopupOpen so the user can select multiple fbx files for merging. It appears you can only select one file at a time. Any help would be awesome! Here is an example of the code:

from pyfbsdk import *

app = FBApplication()

Save the file using a dialog box.

saveDialog = FBFilePopup()
saveDialog.Style = FBFilePopupStyle.kFBFilePopupOpen
saveDialog.Filter = ‘*.fbx’

Pop up name for UI!

saveDialog.Caption = ‘Merge Animations’

Set pop up default open path using param arg: assetpath

#base_path = self.build_import_path(assetpath)
#saveDialog.Path = base_path

Run pop up UI!

if saveDialog.Execute():
# Once file has closed get chosen file add path details and
# use them to FileOpen
file_chosen = saveDialog.FileName
path_chosen = saveDialog.Path
file_path = f"{path_chosen}{file_chosen}"
app.FileMerge(file_path)

Many Thanks

Steve

One way is to use FBFolderPopup() instead, collect the files in a directory (with your filter) to a listbox in your UI, then add multi-select functionality to the listbox. From there you can select the ones you need to process.

exportedFileLst = FBList()
exportedFileLst.Style = FBListStyle.kFBVerticalList
exportedFileLst.MultiSelect = True

2 Likes

Hello quebrado,

Thanks for your update.

So I use the FBFolderPopup() to choose a directory but how do I use a listbox within my popup UI. This is my only UI I’m using. I don’t have a lot of UI experience in Motionbuilder. I cant believe how hard it is to use compared to Maya’s UI.

The plan was to use the popup to choose animation files which I could iterate into the MB scene . This would be merged animations into a MB scene that has the Character. Any help would be amazing.

Thanks

Ok, so in what I’ve described you’d launch the pop up from a button on a separate tool’s UI. If there is no tool as such and your just going straight to the popup, then you could just grab all the files in the chosen folder to a list and work directly with that to import / merge them, but this is kind of limiting as you’d have to process all files in the folder (you could filter to make sure they were the correct type still).

However you eventually merge your animations, you’ll likely need to set up an FBFbxOptions object to specify which elements / takes you want to merge in from each fbx file.

It’s a pretty obvious question, but have you stepped through manually what it is you’re trying to achieve? Are you trying to load different anims onto different characters (with different namespaces); or multiple anims as multiple takes on a single character; or something else?

Hey quebrado,

I’m writing a MB tool (connected to FBMenuManager() button ) so animators can select (some files) multiple animation files within a directory. These will be merge into an MB scene. The MB scene will already have a Character present. The benefit of this tool will have a the popup open to the directory file location they need to start browsing from. This will be a great way to access animations for male and female and also load rigs into there MB scene without any major browsing for files.

I found an easier way to use a popup UI multi file selection. Since I’m using MotionBuilder 2022 that supports PySide2. I decided to ditch MB UI and use PySide2 Qt widgets. So much easier to get the UI I want. Here is a snippet of modified code to show as an example and help others wanting easier UI.

from pyfbsdk import *
from PySide2 import QtWidgets
import shiboken2

app = FBApplication()

open_defaultpath = “C:/Users”

Below creates a Qt brower pop up that returns a string list of path and animation file names.

file_paths = QtWidgets.QFileDialog.getOpenFileNames(None, “Select File”,
open_defaultpath, “Fbx (.fbx)", "Fbx (.fbx)”)

Still need to setup FBFbxOptions!

Then Loop through these files to be merge into MB scene

if file_paths:
for i in file_paths:
app.FileMerge(i)

I just need to sort out my FBFbxOptions now, which look straight forward.

Once again many thanks for all your help.

Yeah, PySide2 makes some of it easier for sure (and is my go to for UI in Maya / Mobu these days). You’ll need to subclass FBWidgetHolder if you end up wanting to use it to create a UI in Mobu, but you’ve probably already found the example in the Mobu python API reference that shows how to do this as and when you might need it.
Glad you’re sorted anyway.

1 Like