View Full Version : .NET in Maya (similar to Max 9)


djtomservo
08 August 2007, 05:53 PM
Is this even possible? I've been using IronPython for a while and given Maya's now friendliness with Python, is it possible to import the .NET libs/modules into Maya?

Robert Bateman
08 August 2007, 11:50 AM
is it possible to import the .NET libs/modules into Maya?

yes, in that you can bind some managed C++ dll wrapper around Maya, and use c#/VB whatever to interface with Maya. It would however involve a lot of work, and wouldn't be all that portable (ok, so you could bind in mono instead). I'd still recommend C++ and mel to be honest.

djtomservo
08 August 2007, 05:31 PM
It does sound like a rather daunting task, i've spoken to some folks that have done various maya to .net projects with varying degrees of success. I've found tons of sample code out there for simple CLR hosts so i think the approach i'm going to take is wrapping some of that in a maya plugin that loads a managed DLL and wraps the calls in maya commands. Man i wish had more than 2 weeks to figure it out:-D

Soviut
08 August 2007, 03:11 PM
Let us know how it goes. I've had fleeting dreams of wrapping the maya API so I can write C# apps.

djtomservo
08 August 2007, 03:54 PM
actually wrapping the Maya API doesn't sound like too bad of a task, I know at least a couple of groups that have had success using SWIG to generated wrapped versions of the API. I'm more interested in taking existing .NET code and running it in Maya somehow. We have a bunch of .NET 3ds Max Tools and it would be cool and be able to take the .NET part of the code and only have to change the MAX-specific stuff to Maya calls, but still leave stuff like UI in place.

DennisRoche
05 May 2008, 11:43 PM
Hi,

Did you have much success with using .NET in Maya??

I'm thinking either:
1) wrapping the Maya API with SWIG; or
2) using IronPython to load the Maya Python API (which really is SWIG).

djtomservo
05 May 2008, 12:42 AM
This is all thanks to John Creson at Autodesk, he figured out how to get this to work.

Not sure about IronPython, but Python for .NET (or just Python .NET) works pretty well, you can read about it here:

http://pythonnet.sourceforge.net

If you want to actually try it out you need to get the binaries from:

http://feihonghsu.blogspot.com/2008/02/installing-pythonnet-20-alpha-2-on.html

Also, I would recommend uninstalling any and all versions of the .NET Framework you have on your machine and just installing the most recent cut of the 3.5 .NET Framework (this will install .NET 2.0 as well, which is what you need for Python .NET). There's a little more to it, but i'm not at my work machine so i can't off the top of my head give you the deets on where to put everything, but i'll post a follow up tomorrow. This method gives you access to both .NET assemblies as well as the existing Maya Python API, which obviates the need for .NET bindings for the API (unless you really need them, i suppose).

DennisRoche
05 May 2008, 11:39 PM
thanks tom. much appreciated.

i will post a demo/tutorial when i get it working.

djtomservo
05 May 2008, 12:23 AM
thanks tom. much appreciated.

i will post a demo/tutorial when i get it working.

No prob, yeah the short is basically you just have to stick the two files (clr.pyd and Python.Runtime.dll) into your Maya2008/bin (or any directory on your PYTHONPATH i would imagine) and then just use Python .NET per the docs. There are some threading considerations if you want to use Forms but for just reflecting on an assembly it should be pretty straightforward.

Pookyjuice
08 August 2008, 09:22 PM
Hey DJ, I've tried to get Python .NET working with Maya by putting those two files somewhere in my Python Path- but when i try to import the clr module I get:
"ImportError: dynamic module does not define init function (initclr)".
Im running Maya 2008 64bit on WinXp64, is there something else I have to check to get this working? I've been banging my head on the wall for some time on this one...

djtomservo
08 August 2008, 09:47 PM
Hey DJ, I've tried to get Python .NET working with Maya by putting those two files somewhere in my Python Path- but when i try to import the clr module I get:
"ImportError: dynamic module does not define init function (initclr)".
Im running Maya 2008 64bit on WinXp64, is there something else I have to check to get this working? I've been banging my head on the wall for some time on this one...

That particular error does get thrown a bit when trying to run 32 bit libs under 64 bit environs, but i have seen some talk of 64 bit builds of the Python .NET libs floating around. Let me do some digging and i'll get back to you on this, i'm actually in the process of firing up 64 bit Python .NET at work. The short fix would be to grab the source distro and rebuild it against 64 bit libs.

djtomservo
08 August 2008, 09:37 PM
Hey DJ, I've tried to get Python .NET working with Maya by putting those two files somewhere in my Python Path- but when i try to import the clr module I get:
"ImportError: dynamic module does not define init function (initclr)".
Im running Maya 2008 64bit on WinXp64, is there something else I have to check to get this working? I've been banging my head on the wall for some time on this one...

Some tips on getting this to run under 64 bit from John Burnett over at Blizzard:

". . .make sure you download the SOURCE for python.net from http://sourceforge.net/svn/?group_id=162464 and build it yourself... The latest release that's zip'd ("2.0-alpha2-clr2.0") will NOT work. I checked in a chunk of changes a few months ago to get it working for 64bit, but there hasn't been a new release since then. . ."

Hope that helps!

CGTalk Moderation
08 August 2008, 09:37 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.


1