3dsmax.exe - wait until script finishes executing

Hey everyone, thanks in advance for the help.

I'm running a simple script to turn on some VRay IR Map settings. The script loads a file, switches some options, saves the file, then quits 3dsmax. (Full script at bottom of post).

I'm running this script through the command line (3dsmax.exe -q -silent -mi -U MAXScript C:\myscript.ms), and then immediately afterwards I'm running a normal render using 3dsmaxcmd.exe, all as part of a program that executes automatically.

My problem is that the first command, to run the script, seems to "finish executing" immediately, and then in the background Max opens up, runs the script, and closes. However in the meantime my program has moved on to the next command, to render the scene file, and I get a problem opening up the scene. I'm assuming this is because it's still open from the first process.

So I need one of two solutions:
1. Tell 3dsmax to wait until the script has completing executing.
2. Run my script and do my render all through the same command.

This script (very basic, and works when I run it independently):
scene_file = "PATH_TO_SCENE"
output_path = "PATH_TO_OUTPUT"

loadMaxFile scene_file quiet:true

vrayObj = renderers.production
vrayObj.options_dontRenderImage = true

vrayObj.adv_irradmap_mode = 0
vrayObj.adv_irradmap_dontDelete = true
vrayObj.adv_irradmap_autoSave = true
vrayObj.adv_irradmap_autoSaveFileName = output_path

saveMaxFile scene_file quiet:true

quitMax #noPrompt

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Anubis's picture

...

You have 2 commands in .bat file.
The 1st call 3dsmax.exe, the 2nd - 3dsmaxcmd.exe?

If so the 2nd command will start immediately after 3dsmax.exe load completely, and not after the script execution, as you may expect.

But if you put your 3dsmaxcmd.exe command in a separate .bat file and then start it from your script (myscript.ms) s'd go fine. So can insert a line of code just before "quitMax #noPrompt":

shellLaunch "C:\\my_cmd.bat"

my recent MAXScripts RSS (archive here)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.