This Zip- file Script package file can be run like an ordinary .ms file. Any secondary files, needed by the tool, will be either automatically found in the package or they will be automatically extracted to specified locations prior to running the main tool scripts.
The file type for script packages is '.mzp' . These files are recognized as executable script files in the following situations:
Auto-loading at MAX startup, in scripts\startups, stdplugs\stdscripts, etc. any .mzp file found is run.
Choosing the Run Script menu item in the main MAXScript menu, or in the Listener menu, now shows .mzp files as one of the default kinds of executable files in the Open Script dialog and will run it if selected.
Specifying a fileName: parameter when adding a callBack script.
As executable files inside other .mzp archives, you can nest them if want.
When using the fileIn <fileName> function, you can specify a .mzp package for fileIn.
The package startup control file is 'mzp.run'. When a .mzp package is opened, it is scanned for an 'mzp.run' file and, if found, the package commands in it are executed in sequence.
If there is no mzp.run control file in the package, MAXScript will unzip all the files in it to a unique temporary directory in the system temp directory and run all the executable script files it finds, in unspecified order. The kinds of rundle script files in a .mzp package are .ms, .mse and nested .mzp files.
When the contents of the .mzp file is extracted to a destination folder, either the default temp folder or one defined in the mzp.run control file, MAXScript will build and replicate any folder structure that is present in the .mzp file.
When you cause a script file inside the package to be run, either through 'run' commands in the mzp.run file, or by the default running scheme described in the previous item, the package becomes a search context for files that the script may try to open while it is running such things as image .bmp files, include files, etc. Only files named by relative path names are searched for in the package, fully specified paths (with device names at the front) will be looked for at the specified location.
The names of files and directories in commands that take them now can be supplied WITHOUT surrounding double quotes if the name contains only the following kinds of characters:
which covers most file names. Any file names with embedded spaces or punctuation not in the above list needs double-quotes.
The zip package is a text file that contains one or more of the following commands. All are optional.
Describes the package. Normally, a readme file in the package would give extended operating instructions, if they are provided.
Returns the version number of the package.
Specifies the location in which to extract the contained files. This can be an absolute path name (starting with a drive letter or \) or a relative name. Relative names are taken as being relative to the default temp directory. The special prefix $max can be used to specify the main MAX executable directory
If the package is launched from a MAXScript run menu item or via a fileIn() function, run the named script file. There can be more than one run command and they are run in order. These are ignored if the package is launched via a fileIn() call that is supplied with an explicit script file to run. During the execution of an mzp.run file, any 'run' commands are ignored. See mzp drop protocol for details.
If the package is launched by drag-and-drop into MAX, run the named dropScript file. There can only be one of these per msp.startup file.
Copies the named file or files (if the <files> string contains wild-cards) to the given directory. The special $max prefix can be used here.
Cause the temporarily-extracted files to be deleted once all the nominated scripts are run or dropped.
Cause the temporarily-extracted files to be deleted when the currently running MAX session exits.
Cause the temporarily-extracted files to be deleted when a file open or reset is performed.
Prevents any deletion of the extracted files.
Opens the named MAX scene file.
Merges the named MAX scene file.
Xrefs the named MAX scene file.
Only one 'open' or 'import' command may be used per mzp.run file. Any number of 'merge' and 'xref' commands can be used.
The following functions will perform searches for files given as relative file names in the current package file:
loadMAXFile <filename> mergeMAXFile <filename> ... getMAXFileObjectNames <filename> importFile <filename> ... loadMaterialLibrary <filename>
The following UI items will search for named bitmap .bmp files in the package:
bitmap <name> fileName:<filename> button <name> images:<image_spec_array> checkButton <name> images:<image_spec_array>
Relative file names can contain path names, so
copy "<from>" to "<to>" [noReplace] move "<from>" to "<to>" [noReplace] treeCopy "<from>" to "<to>" [noReplace] treeMove "<from>" to "<to>" [noReplace]
These cause files from within the package to be copied or moved as specified. The treeCopy & treeMove variants move whole nested directories of files. By default, any existing files in the destination location are replaced with the newly extracted ones, add the 'noReplace' keyword to prevent this.
The <to> spec must always be a directory. Any treeCopy/Move replicates the source sub-directories into the <to> directory, making new directories as needed. The <from> spec for copy & move may be any relative or fully specified file name or wild-card pattern. Relatively named files are looked for in that relative position in the package. Fully specified names are looked for in the main file-system.
The <from> spec for treeCopy/Move may be just a directory path, in which case the whole directory and its subdirectories are copied/moved, or it can be a wild-card path name in which case just the matching files or directory trees are copied/moved.
The file path names you can specify in the various commands (extract to, run, copy, move, etc.) can have a starting path that is one of several special names beginning with $. These name useful locations in the currently running MAX installation.
$max - main MAX executable directory $maps - first directory in Maps directory config $scenes - scenes directory $fonts - fonts directory $imports - imports directory $sounds - sounds directory $matlibs - matlibs directory $scripts - scripts $startupScripts - auto-load startup scripts $plugins - first in the Plug-ins directory config $plugcfg - plugcfg $images - images $ui - UI $macroScripts - macroScripts in UI directory $web - web directory $temp - system temp directory
These directories reflect any customization the user has set up in the various preference dialogs.
As an added feature, if the scripts run from within a package define any functions, macroScripts, plug-ins, rollouts, or any major MAXScript value or construct that might live longer that the running script, then the package is 'associated' with that defined value or construct and will again become the initial search location whenever the functions or handlers in the rollouts/plug-ins/macroScripts/etc. are later run.
You can initially create a .mzp with a zip utility such as WinZip. You can then associate that utility with the .mzp type, so simple double-clicking a .mzp file will open it in that editor. You only need to set up this association once, and you can do this in the Windows Explorer by selecting a .mzp file, shift-right-clicking on the selected file and choosing "Open with..." in the popup menu that appears. Scroll the application list that appears to find you desired zip utility and check the "Always use this program ..." checkbox at the bottom of the dialog.
The MAXScript zip package interface has exposed 2 MAXScript-callable functions:
The 'fileInPackage' function is essentially the equivalent of:
and will return true if success or false if there is a failure, or a missing or invalid .mzp file, and it will also return the directory that the package file were extracted to in the pass-by-reference <extractDirVar> argument.
The 'unloadPackage' function performs an extract and executes all the file copying and moving commands in any enclosed mzp.run file, but will not execute any scripts in the package. The extractTo directory and any 'drop' command file found will be returned in the pass-by-reference arguments.