Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk 3ds® Max® / MaxScript / Startup Scripting
  RSS 2.0 ATOM  

Startup Scripting
Rate this thread
 
25441
 
Permlink of this thread  
avatar
  • buckdog
  • Posted: 11 April 2009 08:42 PM
  • Total Posts: 76
  • Joined: 22 September 2006 03:38 PM

I’m trying startup scripts for the first time to fix a problem.

Problem: a material’s supersampling does not function until I toggle the enable button on/off once.  So when I network render the file the supersampling isn’t on because I cannot interactively toggle it.

I’d like to fix that.  But in the meantime....

I thought I’d create a startup script to toggle the Super Sample enable in Material Slot 1 on and off (and then it will render on), but I haven’t been able to get it to work.  I can run the startup script with the scene loaded and the enable toggle goes off, but when I launch the file, it does not go off.

I’m guessing the script toggles the value in slot 1 when MAX loads blank, then when the actual scene loads, the file has alreay executed and it is too late.

Anyone know how to execute a .ms script that will run after my scene loads and work when the scene is sent out through Backburner?

Thanks
Buck Wyckoff
Buckward Digital



Replies: 0
avatar
  • PerPixel
  • Posted: 11 April 2009 09:26 PM

We need to use a Callback to do this. Callbacks are event triggered by Max and you can execute your own script from when the one you want is triggered. Read the General Event Callback Mechanism topic in the maxscript help. An event exist for FileOpen and also pre render and post render.

Hope that help!



Replies: 0
avatar
  • buckdog
  • Posted: 12 April 2009 05:31 AM

Thanks.
This seems like it will help.
I have done some MAXScripting but I am not a programmer and I find it slow and painful to understand the help.

I tried it without success so far.

They don’t say how to load a callback, so I guessed it is in a ms script.

I created a script called togglecallback.ms.

In it I wrote:
callbacks.addScript #preRender filename:"toggle.ms" persistant:1

toggle.ms has two lines to toggle the material slot 1 supersampling enable off then on....like I would when do it interactively.

I ran the script to load the callback.  Then I saved the file (I thought the callback is now part of the file...persistant).
Then I reloaded the file and rendered the scene, but the supersampling was not working.

I’ll try it again tomorrow, but if someone knows where I messed up my procedure or syntax, fell free to let me know.

Thanks.



Replies: 0
avatar
  • Location: West Midlands, England, UK
  • Total Posts: 14445
  • Joined: 06 August 2007 11:06 PM
  • Permlink of this post

A few things.

You didn’t specify the location of “toggle.ms” (may or may not be relevant)

Persistent: <true or false> (not 1 or 0) i.e. it’s a boolean value. Moot point, probably, but better to go with the pre-defined constants.

To have something run immediately the file is loaded, I think it would need to be non-persistent (though I’m not 100% certain on that). Also, it will happen every time you load a scene, including Maxstart.max if you have one.

callbacks.addscript #FilePostOpen filename:<your file here> id:#<your unique id here> persistent:false

Needs to be saved in one of the specified locations, see “startup scripts” in the help.

Finally, please put your Max version (and brief system specs) in your sig - it can make a difference to the answers you get due to the differences in maxscript between versions.



Max 4.2 through 2013.
XP-64 (SP2)
NVidia 9800GTX-512 (Driver 266.58).
Core 2 Quad Q6600 2.4GHz, 8Gb Ram, DX9.0c.

Replies: 0
avatar

Also just in case you missed it, persistent is written with an E and not an A in the end. persistEnt, not persistAnt.
So your callback might not be part of the file after all.
Specifying where the .MS file you are running will be would be a good idea too - MAXScript uses the current directory to locate files to load via FileIn() and callbacks.



Borislav “Bobo” Petrov

Replies: 0
avatar

And if you didn’t get enough directions to look into…

You can run a script at render time...waaaay at the bottom of the render setup dialog.
There’s a pre and post script option. This script will fire before the render starts
(or after).

Perpixel mentioned it, but I think you missed it.



Replies: 0
avatar
  • buckdog
  • Posted: 18 April 2009 12:59 AM

Thanks for all the input.
I’m up against a deadline in three days, but I’ll look into afterwards.
Tschuß



Replies: 0