Startup Scripts

When 3ds Max is first started, MAXScript searches for any startup script files that it then automatically loads and runs. This feature is useful if you have function libraries you always use and want preloaded, or if you want to establish custom UI settings, define scripted plug-ins, or load scripted utility rollouts.

When 3ds Max starts up, it will always follow the script loading order described below. Certain parts of the software will still not be up and running at different stages of the startup process. Understanding the order and the reasons for it will help you organize your code and have all functions and UI auto-loading and working correctly together.

NOTE:3ds Max looks for scripts of type .ms and .mcr. If you have scripts that you don't want to load automatically, for example library scripts you explicitly load in other scripts, you can give them the .mxs extension. This extension is still recognized as executable by the MAXScript Editor.

Launching 3ds Max Without a File

STEP 1 - Standard Scripts

3ds Max will evaluate the shipping scripts found under stdplugs\stdscripts. These define functions needed by several scripted elements of the base 3ds Max software.

If you need to have some functions/global variables defined for use by your own MacroScript, those should go into an .ms file in stdplugs\stdscripts. This will ensure that they will be defined first.

STEP 2 - User-Defined Plug-in Paths

Next, 3ds Max will load script files in directories defined in Customize... > Configure Paths... > Plug-Ins and their subdirectories. Note that this is different from the way regular plug-ins are loaded. Plug-ins will only load from the specified path and not search sub-directories. Here you can define functions, methods, and structures used by other scripts, particularly MacroScripts.

The 3ds Max scene has not been created and the viewports have not been created at this point. You cannot create scene objects or do anything UI related in these scripts. Of course you can define functions that do these operations, you just can't call these functions at this point.

In this pass, any script files with the name startup.ms are ignored. This allows you to place your scripted plug-in scripts in the plug-in folders for automatic loading. They can be managed like DLL plug-ins, and used to organize your startup scripts into groups in their own directories for easier management. You can prevent a nested directory from being scanned by placing its name in parentheses, for example "(old-versions)", allowing you to enable and disable scripts in handy directory-based groupings.

STEP 3 - MacroScripts

Next, MacroScript .mcr files in ui\macroscripts will be evaluated - they define Action Items that can be displayed in the UI. At this point, UI has not been built yet, the MacroScripts will be needed to fill in their related buttons.

STEP 4 - Startup Scripts

Finally, the startup.ms and then any scripts found in the startup folders will be evaluated. At this point, scene, viewports, and UI are up. You can do anything here you want.

In 3ds Max 9 and higher, startup scripts in the 3ds Max system startup scripts directory are run first, then the startup scripts in the user startup scripts directory are run, providing that the user startup scripts directory is different than the max system startup scripts directory.

MAXScript first searches for a file named startup.ms in the following directories, in the order listed:

  • The user scripts directory

  • The user startup scripts directory

  • The3ds Max system scripts directory

  • The3ds Max system startup scripts directory

  • The 3ds Max executable main directory

  • The Windows NT 32-bit system directory (system32)

  • The Windows 16-bit system directory (system)

  • The Windows directory

  • The directories that are listed in the PATH environment variable

MAXScript stops searching when it finds the first occurrence of startup.ms.

The automatic loading of startup script files can be deactivated by turning off the Auto Start MAXScript option in the MAXScript page of the Preferences dialog, as described in the MAXScript Preferences Settings topic in the main product online help.

Launching 3ds Max With a File

Consider the following two use cases:

  1. Starting 3ds Max from the command line, eventually with a command line script:

    3dsmax.exe somefile.max
    3dsmax.exe somefile.max -U MAXScript somescript.ms
  2. Dragging a.MAXfile onto a 3ds Max shortcut on your desktop

In both cases, 3ds Max boots up as described above and then loads the file.

In 3ds Max 2009 and earlier, the order of script folders and callbacks getting executed was as follows:

Folder / Callback Processed

Comments

stdplugs\stdscripts\

3ds Max scene and UI not created yet.

plugin paths

3ds Max scene and UI not created yet.

MacroScripts

UI not created yet.

#filePreOpenProcess

Scene created.

#filePreOpen

Startup scripts not loaded yet!

\Startup

File objects not accessible yet!

.MAX File

Loading the command line / dropped file

#filePostOpen

Scene objects are accessible from here on.

#filePostOpenProcess

File has finished loading.

-U MAXScript script

Executing the command line script (if any)

As result, scripts loaded from the \Startup folder could NOT be used by #filePreOpen event callbacks!

In 3ds Max 2010 the load order has been changed to:

Folder / Callback Processed

Comments

stdplugs\stdscripts\

3ds Max scene and UI not created yet.

plugin paths

3ds Max scene and UI not created yet.

MacroScripts

UI not created yet.

\Startup

UI Created. Startup scripts loaded before callbacks!

#filePreOpenProcess

Scene created.

#filePreOpen

File objects not accessible yet.

.MAX File

Loading the command line / dropped file

#filePostOpen

Scene objects are accessible from here on.

#filePostOpenProcess

File has finished loading.

Command Line -U MAXScript script

Executing the command line script (if any)

See Also