Hi, Guys, sorry this is bit late but its been one of those weeks. Better late than never I guess. Anyways there a a couple of ways to get python to talk to max and vice versa. The simplest way being COM. This of course requires that you have max registered as a COM server and that you have some MXS function visible to COM (if you have not used com before check the Example scripts on 3ds max disc for getting com going, very easy to do).
First off the code im posting is the most simple of examples! but it should give you a glimpse of what could be possible, which is allot. Fist off create a really simple function in max:
fn DoSomething obj = ( try( execute obj return true )catch( return false ) ) registerOLEInterface #(DoSomething)
As you can see there is a ultra simple function that will just execute whatever is parsed to it. Now for the Python part, this will require the win32 module.
#Import win32com. import win32com.client #Create a connection to Max conn = win32com.client.Dispatch("MAX.Application.9") #Flag as a Method otherwise python or win32com will most likely treat it as attribute. conn._FlagAsMethod("DoSomething") #Call 'DoSomething' #obj.DoSomething("Box()") Thanks to Joel Hooks for pointing out the typo.. conn.DoSomething("Box()")
With any luck you should have a box sitting in the middle of you view port. As I said above this is a very simple example, I will post some more exciting ones! Its worth mentioning that python can be called from max in much the same way, although the best* work flow (at least i think so) is to create a python server, which listens for and queries max, this has some awesome work flow implications, ie lots of artists working on the same job it becomes very easy all the sudden to keep things in sink like camera animation for example... did someone say camera server? Hope thats enough to get you guys started, as I said I will post more stuff soon! Cheers Dave