- Showcase
- Training
- Downloads
- Blogs
General
Autodesk 3ds Max
- Maxed Out
- Taking it to the Max!
- Louis Marcoux Blog
- The 3ds Max SDK Blog
- With Design in Mind
- Max Station
- Max Nation
- 3ds Max & Moritz
Autodesk Softimage
Autodesk Mudbox
Autodesk Maya
Creative Finishing
- Forums
- inHouse
- Careers
- Products
Product Communities
- Events
- Gameware

16 Comments
Yannick Puech
Posted 21 March 2009 8:06 pm
The .NET framework is very powerful and with IronPython even more!
I'm interested in your managed C++/CLI assembly because I'm also doing .NET stuff with Max. I think we can do lot of things in MAXScript and the SDK that were not possible before.
nw42
Posted 1 April 2009 12:34 am
thanks
nw42
loocas
Posted 10 April 2009 3:20 pm
Switcher
Posted 13 May 2009 5:30 pm
thanks !
loocas
Posted 13 May 2009 8:19 pm
Please, keep the great work up!
loocas
Posted 13 May 2009 11:58 pm
PythonEngine = dotNetClass "IronPython.Hosting.PythonEngine"
resulting in: undefined
Do you know why that might be? Is it because IronPython isn't among my PATH variables? (installed only the bin version) Or is it something else?
Christopher Diggins
Posted 14 May 2009 12:07 am
BTW: thanks everyone for the encouragement! I won't be able to get back to working on this for a few months (other products calling, and I have paternity leave coming up). However, I will get back to this as soon as I am able.
loocas
Posted 14 May 2009 12:14 am
However, I wasn't able to fix the "undefined" problem.
I didn't install IronPython, only unzipped the binaries, that's why I thought at first that it was related to the PATH env. variable. However, not even after copying IronPython.dll to the root of 3ds Max was I able to make it past the two initial lines of code.
I simply cannot define the "IronPython.Hosting.PythonEngine" class
PythonEngine = dotNetClass "IronPython.dll"
Same result: undefined
Christopher Diggins
Posted 14 May 2009 12:27 am
My blog was a little misleading. Combine the first two steps (and replace the path to wherever IronPython is on your machine) and you should be good to go:
Assembly = dotNetClass "System.Reflection.Assembly"
Assembly.LoadFrom "C:\Program Files\IronPython 2.0.1\IronPython.dll"
PythonEngine = dotNetClass "IronPython.Hosting.PythonEngine"
engine = dotNetObject PythonEngine
Let me know if this works.
loocas
Posted 14 May 2009 12:33 am
Assembly = dotNetClass "System.Reflection.Assembly"
Assembly.LoadFrom "O:\RnD\Python\IronPython\IronPython-2.0.1\IronPython.dll"
PythonEngine = dotNetClass "IronPython.Hosting.PythonEngine"
engine = dotNetObject PythonEngine
I get: undefined for the part where I try to instantiate the PythonEngine class, after that an error for the engine instantiation.
I can substitute the PythonEngine string with a full path to the .dll, but to the same result.
I'm running a 64bit version of Win Vista Business (as an Admin), and a 64bit version of 3ds Max 2010 if that changes anything...
Christopher Diggins
Posted 14 May 2009 12:42 am
loocas
Posted 14 May 2009 12:52 am
I'll try to investigate further, but this is sad as I was really hoping to get Python code up and running from within 3ds Max even without the luxury of being able to access Max classes and objects, still it'd be a huge step forward for my studio.
Thanks a lot, however, for your time and efforts, at least your technique brought me on this path for which I'm really grateful! Thanks!
If you'll be at Siggraph this year, I'll buy you beer
Yannick Puech
Posted 14 May 2009 2:11 am
I have been able to use IronPython in Max very quickly but at the beginning I was not been able to run Chris code too. Using Reflector tool (http://www.red-gate.com/products/reflector/) I was able to find how to create an IronPython engine and run a script.
Here is my code to run an IronPython script from MAXScript:
(
Assembly = dotNetClass "System.Reflection.Assembly"
Assembly.LoadFrom "C:\IronPython-2.0.1\IronPython.dll"
ironPythonHosting = dotNetClass "IronPython.Hosting.Python"
pythonEngine = ironPythonHosting.CreateEngine()
pythonEngine.ExecuteFile("C:\Code\Python\maxFormTest.py")
)
And the maxFormTest.py example:
import clr
path = "C:\\Program Files\\Autodesk\\3ds Max 2009\\"
clr.AddReferenceToFileAndPath(path + "MaxCustomControls.dll")
import MaxCustomControls
class maxFormTest(MaxCustomControls.MaxForm):
def __init__(self):
self.Text = "MaxForm Test"
self.Name = "maxFormTest"
maxForm = maxFormTest()
maxForm.ShowModeless()
Christopher Diggins
Posted 14 May 2009 2:14 am
loocas
Posted 14 May 2009 2:53 am
It works! Thanks a lot mate!
By the way, is there a way, out of curiosity, to execute Python code directly? I mean without the need of saving it in a .PY file and executing it from the file? I tried the .Execute() method, however, it doesn't work as I expected. For example:
pythonEngine.Execute("print 10") returns:
-- Runtime error: dotNet runtime exception: Late bound operations cannot be performed on types or methods for which ContainsGenericParameters is true.
Do I have to convert the string into a dotNET compatible string or is there something else?
Btw: thansk for the .NET Reflector tip, it's great!
Snoelk
Posted 18 October 2010 12:11 pm
right now im trying to attach to dll shiped within max. but how you can expose the scene directly to .net and write your stuff directly within c# ?
Add Your Comment
You must be logged in to post a comment. Login here or Register