We are re-writing our asset pipeline with the core of it in C#, and individual utilities can interact with those core classes (actually just one class, that uses other .NET classes). Integrating this into our max tools have been painless. However, I am at a loss for the best way to integrate this into our Python tools. Basically, I want to do something as simple as this, if it were MAXScript:
data = DotNetObject "AssetPipeline.AssetData" assetName
gr2Filename = data.Gr2Folder + assetName + ".gr2"
Is there any way to do this other than moving over to a full IronPython deploy? Our needs are small, I’d like to keep deploy simple, but most importantly, I am piggy-backing these pipeline changes on stuff needed for our E3 demo and can’t delay at all. I’d like to find the simplest possible way to do this, if there is a simple way- if it requires a real IronPython deploy and pipe conversion, I may hold off until I have time to set it up properly and set up an IDE with it (we are still using IDLE and I’m sick of it). So hence why I’m taking the easy way out and asking here
Thanks.
There’s always COM to consider. Your C# core could expose COM interfaces for all the methods you need to reach, and you call those from Python (or VBScript, other languages for that matter).
COM only supports standard data types like string, int, float, simple lists, etc. so you’d need a little wrapper code to keep your above example to just two lines. Like a method of deserializing a string value from C# into a Python object you can hit with dot notation. But should be entirely doable.
As for IDEs, Wing IDE is still tops in my book. Awesome Python features, full debugger (including remote), extendability and the best support I’ve ever seen.
[QUOTE=Rob Galanakis;2906]
data = DotNetObject "AssetPipeline.AssetData" assetName
gr2Filename = data.Gr2Folder + assetName + ".gr2"
[/QUOTE]
Python .NET would do this pretty easily. It’s also a much smaller deployment than IronPython, just two files. If i remember correctly, the most recent trunk includes some fixes that make Python .NET work off of a PYTHONPATH directory, so you may even be able to just put the two required files in a blessed location…
Hmmm Seth any more details would be much appreciated. I am a noob in some ways, especially on the OS level of things. Any specifics on setting that up would be much appreciated (like a walkthrough, for a child).
[QUOTE=Rob Galanakis;2924]Hmmm Seth any more details would be much appreciated. I am a noob in some ways, especially on the OS level of things. Any specifics on setting that up would be much appreciated (like a walkthrough, for a child).[/QUOTE]
So here’s the official site for Python .NET:
http://pythonnet.sourceforge.net/
You can find links to the source tree and the docs there. I would actually recommend getting the trunk from sourceforge and building the files yourself since you probably won’t find a pre-built set of binaries for your specific configuration on that site. Also if you need 64-bit support (props to the Blizzard guys for that!).
Once you’ve got the files built, the short of using it is just parking the two files (Python.Runtime.dll and clr.pyd) either next to your interpreter or on your PYTHONPATH and importing .NET assemblies as you would normal Python modules/namespaces. So given the example you posted (im making some assumptions about the namespaces and assemblies here):
import clr
import sys
sys.path.append(<path to AssetPipeline assembly>)
import AssetPipeline
data= AssetPipeline.AssetData( assetName )
gr2Filename= ("%s%s.gr2" % (data.Gr2Folder, assetName) )
Again, i’m guessing as to the structure of your assemblies, but something like that…