I’m experimenting some with this python craze… and i’ve run into a small snag, I can’t seem to get my pywin32 to load at all.
I started by going through the examples included with the GDC2008_PythonSamples and working up something of my own. its going fairly well so far.
I’d like to get into the max/Com stuff but I’m getting an error while trying to load the com clients, from random net searching it seems to be due to pathing but I’m not sure where to look to fix it?
[B]ImportError: DLL load failed: The specified module cold not e found.[/B]
File "[B]z:\python\pyAssetBrowser.py[/B]", line 9 in <module> import win43com.client
File "[B]C:\Python25\Lib\site-packages\win32com\__init__.py[/B]", line 5, in <module> import win32api, sys, os
the error is coming up from the import win32com.client line in my script…
32bit… looks like a installing by way of right clicking on the file and using Run As Administrator fixed THAT error… now to figure out what these other errors mean
Edit: Ok, giving me an invalid class string on the Max.Application, so i’m downloading a com browser to see whats going on there… headway!
That’s the second time I saw someone have that same problem today with my sample scripts. Seems I skipped something in the setup steps.
What you need is to tell Windows that Max is an application with a COM interface.
To do that: Open Max and run the attached MaxScript. This does a one-time add of the necessary info to Windows registry. It will work in any Max release from 2008 or newer. If you have Max 9 or earlier, you’ll need to have the avguard extensions loaded first.
Then run the “register_python_com.ms” that comes with my samples. This registers the “execute” MaxScript command with the COM interface, allowing you to send in MaxScript command strings from other apps. You can put this script in scripts\startup to make it load every time.
Then you should be in business. When I’m in the office Monday I’ll get that registerComApp script added to the PythonSamples archive.
Also do yourself a favor and disable Vista’s User Account Control (UAC), if you haven’t already. Use of COM gets complicated or impossible when this is on.
that registerComApp did the trick, you have to edit the createSpheres.py to flag as command execute instead of the command_from_python though, and it seems to only create the first sphere of the list?
Aaaand… yea i see what you mean about the UAC thing here, i’d left it on after the last reformat just for kicks, it didn’t really start to bother me until i started scripting at home kind of pointless if you need to run everything as admin anyway.
weee… thanks you guys rock. I’m excited, 6 pages of ghetto’d up maxscript just got replaced by a page of python and the python is soooo much faster.
You can call execute directly like that but using command_from_python will ensure all the non-standard data types are returned to Python, at least in some form (as a string, if nothing else). It also works around a COM failure when Max tries to return an empty array to Python.
If you have the registerPythonCom.ms file in your Max’s scripts\startup folder, command_from_python should be available over COM.
Now I understand One to set up the registry items that’s a ‘run once’ sort of thing, and one that’s loaded each time max starts up that handles the meat of the work?
Regardless, thanks a ton for sharing all that info/scripting! hopefully some day i can contribute back some