Notifications
Clear all

[Closed] autorun script on scene open

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?

2 Replies

it’s easy…
you have to use #filePostOpenProcess callback…

Sample:


fn do_something = 
(
 format "% --> post opened
" (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 …

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!