Sunday, September 21, 2014

Maya / Houdini Python live connection

I'm playing a bit with rpc module and python. Here is a little example of what I've tried so far, a live connection between Maya and Houdini.
Maya looks up for Houdini start up and then connects its python to Houdini's automatically. Thanks to that, in this video, I create a "live connected" camera and I can also send meshes directly from Maya to Houdini ( and vise versa ).

This needs the rpyc module for Python 2.7 ( it is also included with Houdini ), you can downloaded it at this adress : http://rpyc.readthedocs.org/en/latest/

Here is the source code for the connection Maya => Houdini. It must be saved in the scripts folder of maya and used as followed from a Python shelf tool:

        import MayaModule
        ui = MayaModule.MayaConnectionUI()
        ui.show()

You can copy the icons green_light.png and red_light.png in a folder "icons" saved in the same place as the python file.

On the Houdini side, you must have a Python file called "123.py" (or hescape.py if you use Houdini Escape ) withthese two lines of code in it:

        import hrpyc
        server = hrpyc.start_server(port=18812)