How to setup Eclipse with MotionBuilder?

Has anyone here have any information on how to setup Eclipse with Motionbuilder? While the default python editor is nice, it still lacks a lot of the funcitonality I’m looking for in an editor.

Thanks for any pointers.

-csa

This weekend I looked into the matter a bit futher. MotionBuilder uses a boost wrapped version of python, and does not ship with any .exe representing python.exe. It uses the MotionBuilder.exe to call boost wrapped python calls from what I can tell.

When setting up Eclipse, you need to give PyDev an .exe to use. Since MotionBuilder doesn’t ship with one, this means you’ll need to have python 2.6 installed on your machine to point Eclipse PyDev to. Once you’ve done that, you need to navigate into your C:\Program Files\Autodesk\MotionBuilder 2010\bin\config\Python\ folder and find a file called “pyfbsdk_gen_doc.py”. This file is basically a module dump of pyfbsdk.pyd which is text readable, and contains only def names with doc strings. This is what MotionBuilder is using for autocomplete.

Knowing this, you’ll need to rename the pyfbsdk_gen_doc.py to pyfbsdk.py, and move it to some other folder on your machine. This file will never run properly, its merely doc strings and function names of the main pyfbsdk module. Add this new folder path containing the renamed file to your PyDev path in Eclipse, restart, and you should start seeing code completion.

This being said, I have not figured out how to send any new .py file contents to motionbuilder over telenet to port 4242 from Eclipse. Seems that the only plugin which appears to have done this at one point in time, is not updated to support version 3.x of Eclipse.

Even if I do find a plugin to achieve this, I’m not certain how debugging is going to fare since you have to point Eclipse’s PyDev plugin to a different python executable then what MotionBuilder is using (since it’s embedded via Boost), coupled with the fact that you are esentially overriding the correct pyfbsdk.pyd with an “empty” version.

Thoughts or comments are welcome on this matter.

-csa

Talk about timely. I am just running into this as well and that was an incredibly helpful tip. The license I have is a 7.5 one though and I had to get the MB 2010 demo to get that file but god willing there will not be much in the way of difference between the two versions of the codebase.

-L

I actually figured out how to send commands from eclipse over to mobu via python, and started a writeup which I’ve not yet finished. It involves you having to write a python transport script, which I’ll just post with the finished article. With the holidays approaching, maybe I’ll get some time to finish it over break. Hit me up with any questions in the meantime.

-csa

any progress on this subject? would be great to have that possibility, thanks

I just recently started programming python in Motionbuilder. Is there an update on using an external editor for motionbuilder?

Gah I wish I had scene this! Was looking for a way to auto-generate the mobu code for autocomplete, and for writing tests against (figured I could mock out the calls).

I have been using Wing now a lot more than Eclipse as of late. Here’s a little diddy I whipped up to generate the necessary pi-files for auto-completion in wing. Note that you’ll have to augment the code to point to your version of Mobu.


import os
import sys

WING_DIR = r'c:\Program Files (x86)\Wing IDE 4.0'
if not os.path.exists(WING_DIR):
    WING_DIR = r'c:\Program Files\Wing IDE 4.0'

MOBU_DIR = r'C:\Program Files (x86)\Autodesk\MotionBuilder 2010'
if not os.path.exists(MOBU_DIR):
    MOBU_DIR = r'C:\Program Files\Autodesk\MotionBuilder 2010'

sys.path.append(os.path.join(WING_DIR, 'src', 'wingutils'))

MOBU_FILES_DIR = os.path.join(MOBU_DIR, 'bin', 'config', 'Python')
sys.path.append( MOBU_FILES_DIR )

import generate_pi

PI_FILES_DIR = os.path.join(os.environ['AppData'], 'Wing IDE 4', 'pi-files')

# Map Mobu's .py files to the actual pyfbsdk
MOD_DICT = {
    "pyfbsdk_gen_doc":"pyfbsdk",
    "pyfbsdk_additions":"pyfbsdk_additions",
    }


def main():

    for mod in MOD_DICT.items():

        pi_filename = os.path.join(PI_FILES_DIR, os.sep.join(mod[1].split('.')) + '.pi')

        if not os.path.isdir(os.path.dirname(pi_filename)):
            os.makedirs(os.path.dirname(pi_filename))

        print 'Generating .pi file for', mod[0]

        f = open(pi_filename, 'w')
        try:
            generate_pi.ProcessModule( mod[0], file=f)
        finally:
            f.close()

if __name__ == '__main__':
    main()

I know this strays from the Eclipse thread, but hopefully this comes in handy as well :wink:

-csa

Thanks csa! :slight_smile:

I’m a beginner of MotionBuilder (I’m a intermediate user of python).
Recently I have to develop several python scripts to improve the motion builder pipeline of my project.
So I decided to use Eclipse to debug motionbuilder python efficiently.

After installation of MotionBuilder2012, I added the related path to System PYTHONPATH
via Eclipse>Prerference>Pydev>Interprter-Python>Libraries as the following image.


I wrote a very simple python script as follows.


from pyfbsdk import *
myNull = FBModelNull("locator")

After that I tried to run it. But Eclipse outputs the following error:


from pyfbsdk import *
ImporteError: DLL load failed
.

I can’t resolve the problem. Are there any other path to add System PYTHONPATH?

Ideally I want to debug the script by using Auto completion and connection to MotionBuilder.
But I would like to debug the basic part of script on eclipse at first. But I can’t do that due to the above errors.

Therefore if you have any information, I would like you to give me advice.
Should I also use Wing as a debugger for MotionBuilder instead of Eclipse?

Thanks in advance!

[QUOTE=dragonboy765;17173]

I wrote a very simple python script as follows.


from pyfbsdk import *
myNull = FBModelNull("locator")

After that I tried to run it. But Eclipse outputs the following error:


from pyfbsdk import *
ImporteError: DLL load failed
.

I can’t resolve the problem. Are there any other path to add System PYTHONPATH?[/QUOTE]

Are you trying to run it straight from a python shell in Eclipse? Motionbuilder cannot run “headless” like Maya can with mayapy.exe. You can only import pyfbsdk inside of MotionBuilder’s python interpreter.

Wing is best for debugging both MotionBuilder and Maya, in my opinion. However, I do use Eclipse most of the time for it’s superior Pydev features. I just have both apps open. Code away in Eclipse with autocomplete and then set break-points in Wing or have Wing interrupt errors from MoBu and Maya.

BTW, here’s a handy line to put at the top of your scripts to get pyfbsdk to autocomplete:

if False: from pyfbsdk_gen_doc import * #@UnusedWildImport

Just make sure you add the path to pyfbsdk_gen_doc wherever it is located (C:\Program Files\Autodesk\MotionBuilder 2010\bin\config\Python\ ?).

(post explaining better: http://www.jason-parks.com/artoftech/?p=30)

Thank you for your reply kindly.

Yes, I’m trying to run it straight in Eclipse via Run > Run As > Pytnon Run.
Let me make sure your advice. You mean, I can’t debug MotionBuilder python in Eclipse like mayapy.exe?
In other words, I can only debug MotionBuilder python only on MotionBuilder?
If so, it would be very inefficient to debug…
I’m curious about how to debug MotionBuilder efficiently on Eclipse or Wing.

And thank you for your information about Wing and Eclipse(pydev).
According to your great presentation at GDC2011, I know that you use both Wing and Eclipse.
There are strong point and weak point each other.

I hope that I can debug MotionBuilder python by using IDE, such as Wing or Eclipse…
I will check your article on your blog.

Thanks again!