[IronPython] IronPython integration via dotNET

Lukas Dubeda loocas at duber.cz
Fri Oct 23 00:31:12 CEST 2009


Hi there,

me again with the same issue of me trying to integrate IronPython into
3ds Max via .NET. So far, after tons of trials/errors, I've reached
a point where I really don't know where to go next.

I understand most of you won't probably know MAXScript and 3ds Max,
but I bet you're all pretty good at .NET and IP :) so, here's what I'm
doing so far ("--" are single comment lines in MAXScript):

-- I load an assembly class:
assembly = dotNetClass "System.Reflection.Assembly"

-- I load the IronPython dll:
assembly.loadFrom "C:\IronPython-2.6\IronPython.dll"

-- Then I load the iP hosting:
ironPythonHosting = dotNetClass "IronPython.Hosting.Python"

-- now I need the iP runtime:
pythonRuntime = ironPythonHosting.CreateRuntime()

-- I then try to get the Python engine itself:
engine = pythonRuntime.GetEngine("Python")

-- I understand that for running Python code in the current scope
-- I need to create a scope object in order to "listen" to the
-- output of Python, right?
scope = engine.CreateScope()

-- so far so good, now I'd like to execute a simple Print() function
-- in iP and get its output back to Max:
src = engine.CreateScriptSourceFromString("Print 'hello'")

-- unfortunately this is where I hit the major road block
-- when I try to execute the following code block:
src.execute(scope)

I get the following error:

-- Runtime error: dotNet runtime exception: Late bound operations cannot 
be performed on types or methods for which ContainsGenericParameters is 
true.


I have absolutely no idea how to get around this issue and how to get 
IronPython execute the Python code and return whatever it calculates
back to the application I'm running it from so I could catch the return
and use the values from within Max.

Anyone has any idea?

I should also mention that MAXScript is a dynamic scripting language
within 3ds Max and that, even though I know MXS quite well as well as
I know Python and have done tons of scripts and tools with these
languages, I'm not a programmer, I'm a technical artist (as the official
title says :) ).

Thanks a lot in advance, I'll appretiate any tips and hints on this
issue.

- Lukas



More information about the Ironpython-users mailing list