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.
.ms
, .mcr
, .mse,
and .mzp
. 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 Scripting Editor.getMaxscriptStartupState()
function to determine if standard or startup scripts are currently loading, or are loaded.To enhance system security, startup scripts that have the hidden file or system attribute set are not loaded. Scripts that are in a hidden or system folder (other than %LocalAppData%
and %ProgramData%
) are also not loaded. If a script is discovered that meets one of these criteria, it is logged to the system log with the script path and name, the file attributes, and "Action: not loaded".
Available in 3ds Max 2021.3 Update and higher.
Starting in 3ds Max 2022.3 Update: For startup scripts inside the 3ds Max install directory tree, if the 3ds Max install directory, or directories above it, are hidden, then startup scripts will still be loaded. If a directory below the install directory is hidden, for example C:\Program Files\3ds Max\scripts
, then startup scripts in that directory are not loaded. This policy applies to startup scripts in plug-in packages as well, where the plug-in package directory, or directories above it, can be set to hidden, and the startup scripts it contains will still be loaded.
3ds Max will evaluate the shipping scripts found in 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.
Next, 3ds Max will load script files in directories and plug-in packages 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.
Next, scripts found in plug-in packages are evaluated (such as appbundles from the Autodesk App Store). When found in a plug-in package, only scripts that are specified as a PreStartupScript ("pre-start-up scripts parts" in the PackageContents.xml
file) are run during this step. Note that the 3ds Max UI is not yet present at this step.
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.
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. Finally, any scripts from plug-in packages that are specified as PostStartupScript ("post-start-up scripts parts" in the PackageContents.xml file) are run.
MAXScript first searches for a file named startup.ms in the following directories, in the order listed:
As of 3ds Max 2022.1 Update, these directories are no longer searched:
See File Access Function Search Behavior for a list of directories startup.ms searched for.
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.
Consider the following two use cases:
3dsmax.exe somefile.max
3dsmax.exe somefile.max -U MAXScript somescript.ms
.MAX
file onto a 3ds Max shortcut on your desktopIn both cases, 3ds Max boots up as described above and then loads the file.
The order of script folders and callbacks getting executed is 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. |
\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) |