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.

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.

new.gif NEW in 3ds Max 9: 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.

new.gif NEW in 3ds Max 9: MAXScript first searches for a file named startup.ms in the following directories, in the order listed:

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.