dotNET sweetness for Maya

loocas | Maya,Python,technical | Thursday, September 11th, 2008

maya_dotnet_banner

When I first started developing some tools, to speed up and aid our pipeline, in Maya I was furious to find out about Maya’s implemented GUI tools and methods. It was extremely unintuitive, very badly documented (especially regarding examples of the given object etc…) and heavily limiting. What I’d love to have in Maya was something similar to Max’s GUI objects I was used to.

Especially ever since Max 9, where we finally gained access to the beautiful dotNET framework and its objects, classes etc. I was looking for a similar solution. The only problem with dotNET is its platform dependence. As it’s a Microsoft framework it, obviously, only works on Windows. I’ve heard about Mono for Linux, but since I don’t work on Linux and have very limited knowledge of it, I didn’t investigate any further. There are some other options for platform-independent GUI development, like Qt, which I’m yet to go through. It’s definitely worth looking into, but the great advantage of dotNET, on the other hand, is its presence on virtually any Windows machine, which is simply awesome for heavy tools deployment across multiple machines in a studio environment (I can’t imagine making all our artists to install Qt). So, the obvious step was to look for a way to get dotNET run under Maya.

After searching the net, I quickly realized it won’t be such a simple task as with many other tools I’ve ported to Maya in the form of modules for Python. There is IronPython, which runs under its own interpreter, which makes it impossible to implement in Maya (very sad!), but then I bumped into a project, which seems to be lacking a bit of active development, but looked promising: PythonNet.

There’s a little bit of a glitch. There’s no x64 port and, what’s more irritating, the release version I managed to run under Maya only supports dotNET 1.1, which is a real pitty as the tools you’ll be able to create will have slightly limited functionality for more advanced tools development, but nothing that’d cripple the actual usefulness and richness of the platform, only some more advanced and newly added classes or methods won’t be supported.

An example of the dotNET’s listView object used under Maya:
dotNET_listView_in_maya

So, all you need is to download the PythonNet 1.0 RC2 for dotNET 1.1 and install CLR.dll and Python.Runtime.dll in Maya’s bin folder. Done. From there on, you’ll be able to import a CLR module (note the upper-case) and access the dotNET objects and namespaces through it. There are also some nice examples of code to get you going.

Another dotNET example of an actual simple tool I developed for automatic Point Cache assignments:
point_caches_agent

Here, again, Python really excells in these matters. I’m able to develop a fairly complex GUI for my tools and then instance, inherit and mainly overflow the operators of the GUI, so, in the end, I can plot the same GUI for many various functions, which is very useful.

Right now I’m looking into some ways of getting the alpha verision of PythonNet 2.0, which supports dotNET 2.0 objects, to run under Maya in both x86 and x64 modes. If I get it going, I’ll post the way as well as the compiled modules (as I feel it’ll be necessary).

2 Comments »

  1. Hey there!

    thank you for this post, just going to start digging in Dotnet for development :)
    however, i did try to put the DLL files you said in the bin folder but still maya wont let my import the modules…

    import CLR.System
    # Error: ImportError: No module named CLR.System #

    could this because i use maya 2010 and it uses 2.6 python?

    Comment by Erik — February 9, 2010 @ 11:45

  2. Hi, Erik,

    this is most likely because you have to specifically compile the plugin against the concrete version of Maya SDK you’re using. Otherwise it won’t load up the plugin.

    Comment by loocas — February 9, 2010 @ 21:41

RSS feed for comments on this post. TrackBack URI

Leave a comment

Powered by WordPress | Theme by Roy Tanck