Skip to content

Ndgt/Mobu_PluginBase_Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mobu-PluginBase-Python

Original Mobu Python Scripts for daily use


Usage

alt text

Create Tools and Scripts Folder and stor PluginBase.py in the Python Startup Folder.

  • Tools : Folder for tools which will be stored in FBToolList
  • Scripts : Folder for simple scritps
  • PluginBase.py : Imported by Mobu System, then create Menu and associate scripts with it

The following image shows how to arrange them.

alt text

Installer

These modules can be installed automatically using Installer/PluginBase_Setup.exe.
Note: For Windows only


Rules

In the Tools

  • The tool name must be identical to its module.
  • Do not show tool, just create and add to FBToolList using FBAddTool()

How it works

Access to the Menubar

pyfbsdk.FBGetmainWindow() returns the pointer to the MotionBuilder's Mainwindow.
One of the child widget of the Mainwindow is that Menubar.

def getMenubar() -> QMenuBar:
    # get Main Window
    pMainW = FBGetMainWindow()
    if pMainW:
        #Convert pointer to any non-inappropriate type
        MainW = wrapInstance(pMainW, QMainWindow)
        menubar = MainW.menuWidget().children()[1]
        return menubar

Addition of Menu

PluginBase.py creates a Menu and associate scripts with it.
Note that QtGui.QAction.triggered() has checked bool parameter.

mbar  = getMenubar()
tmenu = mbar.addMenu("Tools")
smenu = mbar.addMenu("Scripts")

# if tools
for tools_filepath in tools_dir.iterdir():
    if str(tools_filepath).endswith(".py"):
        FBApplication().ExecuteScript(str(tools_filepath))
        
        # add submenu
        module_name = tools_filepath.stem
        t = tmenu.addAction(module_name)
        t.triggered.connect(lambda checked=False, name=module_name : ShowToolByName(name))

# if scripts
for script_filepath in scripts_dir.iterdir():
    if str(script_filepath).endswith(".py"):
        s = smenu.addAction(script_filepath.stem)
        s.triggered.connect(lambda checked=False, sp = str(script_filepath) : FBApplication().ExecuteScript(sp))

About

Original Mobu Python Scripts for daily use

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published