PDA

View Full Version : autorun script on scene open


robomojo
08-06-2009, 09:26 PM
Hallo!

I want a script to run every time I load a file or open a scene (not just when max starts).

I work with people who love to work in user view and can't help themselves from disabling the viewport. I always want perspective view and enabled viewport. I tend to open files by drag and drop into the viewport - it automatically merges the scene for some reason if the viewport is disabled.

I notice there is an option in preferences > maxscript called "Load/Save Scene Scripts", but can't seem to find out what this really does.

Is it possible to have a script automatically run when any file is opened?

denisT
08-06-2009, 09:44 PM
Hallo!

I want a script to run every time I load a file or open a scene (not just when max starts).
Is it possible to have a script automatically run when any file is opened?

it's easy...
you have to use #filePostOpenProcess callback...

Sample:


fn do_something =
(
format "% --> post opened\n" (maxfilepath + maxfilename)
)
callbacks.removescripts id:#my_postload
callbacks.addscript #filePostOpenProcess "do_something()" id:#my_postload


save this code as file and put it in startup directory ...

robomojo
08-09-2009, 12:44 AM
Ahh! Thank you very much! Now I never have to see a disabled viewport ever again!

This is the script I used, incase anyone else out there is looking for a quick solution.
(It also changes any user view to perspective view)


for i = 1 to viewport.numViews do
(
viewport.activeviewport = i
if viewport.IsEnabled() == false then max vpt disable
if viewport.gettype() == #view_iso_user then viewport.settype #view_persp_user
)


Thanks denisT!

CGTalk Moderation
08-09-2009, 12:44 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.