Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Max python

Max python

Anonymous
Not applicable
1,321 Views
7 Replies
Message 1 of 8

Max python

Anonymous
Not applicable

i have python basics knowledge but am looking for some tutorials and hints for using it in max
where i can find some ???

0 Likes
1,322 Views
7 Replies
Replies (7)
Message 2 of 8

barigazy
Enthusiast
Enthusiast
I assume you're talking about new max2014 extension version. In "scripts" folder you can find "Python" folder with some *.py files, but still I also looking some explanations or example how to use them.
0 Likes
Message 3 of 8

Swordslayer
Advisor
Advisor

Also have a look at both the SDK Documentation and Python API Documentation at Autodesk Media and Entertainment 2014 SDK Documentation page. There are some examples but bear in mind that with basic python knowledge (provided you don't have extensive SDK knowledge) you'd be better off learning MAXScript - at least much more straightforward, less verbose and easy to reason about, especially when working with existing scene. Compare for example any of the sample scripts, for example:

 

import MaxPlus

obj = MaxPlus.Factory.CreateGeomObject(MaxPlus.ClassIds.Cylinder)
obj.ParameterBlock.Radius.Value = 10.0
obj.ParameterBlock.Height.Value = 30.0
node = MaxPlus.Factory.CreateNode(obj)
mod = MaxPlus.Factory.CreateObjectModifier(MaxPlus.ClassIds.Bend)
mod.ParameterBlock.BendAngle.Value = 45.0
node.AddModifier(mod)

# and in max: python.ExecuteFile "demoBentCylinder.py"

 Versus MAXScript version:

 

obj = Cylinder radius:10 height:30
addModifier obj (Bend angle:45)

Another comparison, running the load function of unwrap modifier:

 

import MaxPlus

UNWRAP_INTERFACE = MaxPlus.Interface_ID(1404256411, 419396280)

obj = MaxPlus.Factory.CreateNode(MaxPlus.Factory.CreateGeomObject(MaxPlus.ClassIds.Cylinder))
mod = MaxPlus.Factory.CreateObjectModifier(MaxPlus.ClassIds.Unwrap_UVW)
unwrap = MaxPlus.FPInterface__CastFrom(mod.GetInterface(UNWRAP_INTERFACE))
obj.AddModifier(mod)
obj.Select()
unwrap.Invoke(unwrap.FindFn('load'))

 Versus

 

obj = Cylinder isSelected:true
m = Unwrap_UVW()
addModifier obj m
m.load()

 

As a homework, try to call a function with multiple parameters, there's no FPParams (so what, you might say, it's just an Array or FPValues) but what's worse, there seems to be no way to pass such an array to the Invoke function...

 

That said, I really like it and will certainly be using it a lot in future 🙂

Message 4 of 8

barigazy
Enthusiast
Enthusiast
Thanks Swordslayer, this is very nice info. I use mxs + .net and I realy like this powerful combination.
Can you tell me how (is it posible) to create form ei. window and some basic UI controls like buttons and spinners with python in max. I wonder if I can expect some cool controls which can be created using devXpress or dotNet objects?
0 Likes
Message 5 of 8

Swordslayer
Advisor
Advisor

Sure, although I haven't played with that part myself yet 🙂 You are free to choose almost any route here I would say, although it makes sense to pick PySide/PyQt (PySide, I would say, as it is now coming by default with Maya). There's a note in Python extension libraries, which gives you some info on how to make it work. And then just look for some tutorial based on your choice, like this one: Intro to Qt using Python and Maya; or Baby’s first GUI. And then, there's always Qt Creator, Qt Designer and so on.

Message 6 of 8

barigazy
Enthusiast
Enthusiast
Awesome. I will try this soon. Thanks again 🙂
Cheers!
0 Likes
Message 7 of 8

Anonymous
Not applicable

thanks for your advices Sowrdslayer, its very usefull 
hope to find a full course about max pythoon soon

0 Likes
Message 8 of 8

Anonymous
Not applicable

This is my first time using python call 3dmax`s interfaces,I try to execute the following code in the command line,But encountered exception error:

 

Traceback (most recent call last):
File "E:/pyScript/Test.py", line 2, in <module>
MaxPlus.Core.EvalMAXScript("print #aaa")
File "C:\Program Files\Autodesk\3ds Max 2015\MaxPlus.py", line 33322, in EvalMAXScript
return _MaxPlus.Core_EvalMAXScript(*args)
RuntimeError: Unknown MaxPlus Exception

 

 

tips:I use 3dmax2015

anyone can tell me how to fix it?

 

thanks for any responses!!

0 Likes