tags:

views:

41

answers:

3

Hi All

I am trying to instantiate a program via a python script as follows

os.startfile( '"C:/Program Files/Autodesk/3ds Max 2010/3dsmax.exe"' )

since Max takes a bit of time to load, I wanna wait till it has finished loading completely. I check the task manager to see if "3dsmax10.exe" is in the list, but it's in the list as soon as the process starts (obviously). So is there a way to find out if it has completely loaded or not ?

Any help is appreciated

Thanks

A: 

Complete loading is subjective a bit. As far as I remember 3DS MAX performs plug-in loading—which is an absolutely major part of load time—showing you splash-screen. And only after loading completes it shows its main window.

You can use this fact and constantly monitor existing windows using WinAPI to get to know when the main window appeared. Use title text or wnd-class to find it among others.

nailxx
+1  A: 

You could put a simple maxscript script in maxhome\Scripts\Startup which will be started when max finished starting. This script the could create a file, or talk to your python script through com or tcp.

parceval
+1  A: 

Here is a bit of a hackish (not robust) solution. Starti 3ds Max with a MAXScript script on the command-line. For example

c:\3dsmax\3dsmax -U MAXScript myscript.ms

As Parceval suggests, this script can create a new file using the MAXScript command:

createFile c:\tmp\myfile.txt

Next in Python wait until the file exists (don't forget to delete it first). So altogether:

while not os.path.exists(c:\tmp\myfile.txt):
   time.sleep(1)
cdiggins
Maybe not delete - just 'touch' it to update timestamp.
Rekin
Good alternative.
cdiggins