MZP for Maxscript Distribution

The Issue

Figuring out how to get your scripts out to a team can often be a tough one! Just throwing your scripts out there is simple, but that leaves artists having to copy lots of files or explicitly run things. This isn’t their job and takes up their time. It also leaves so much room for user error!

MZP files, while not perfect, are designed for distributing maxscripts, can be easily version controlled and are easier to create than an exe. (For info on creating exe files with NSIS see Jeff Hanna’s tutorial.)

With an MZP, the user only needs to worry about getting the latest version of a single file* and can then install it by dragging and dropping it from a windows folder into their 3ds max viewport. It handles any file copying or scripts that need to be ran on installation.

6a67aecd550a29a212ea56783be7ab0f.gif

*Please version your scripts separately, especially if you work with other TA’s! You’re not going to be able to diff on this as it’s a zip file by another name. You just don’t need to point artists towards these scripts. 

An mzp is a 3ds max variant of a zip file, which contains the scripts to be installed alongside a script that will run when the zip file is dropped. To make one, bundle your scripts, along side a .run file (covered below) into a zip file, then change the extension to “mzp”.

934a4ad556d5618c74d6e41939b75536.gif

.run File

The .run file is a batch file that is run when the mzp is dropped. This can run command line commands in addition to the ‘drop script’ – a single maxscript file that will be run when the mzp file is dropped.

Here’s an example of a .run file. It contains the name and version of the script, copies some files, runs a script then clears temporary files.

name “myMZPDistro”

version 0.1

treeCopy “myMZPDistro\Scripts\*.*” to “$maxData\scripts\Tools”

treeCopy “myMZPDistro\Config\*.*” to “$maxData\scripts” noReplace

move “*.max” to “$scenes”

drop “myMZPDistro\Scripts\DropScript.ms”

clear temp on MAX exit

Copying

The treeCopy command copies everything from one directory to another.
The first command copies everything from scripts to the user’s 3dsMax folder, found at \AppData\Local\Autodesk\3dsMax\2019 – 64bit\ENU.

The reason I do this is because my tool is split into many scripts (using my fake class method) and I need to explicitly reference them in order for the main macro script to run. I’d recommend using this folder even if you have a single script – every user will have it and nothing will be stored in temporary files!

The second treeCopy command copies a second folder only if the folder doesn’t exist at the destination. This noReplace option is really handy for things like user settings, especially if you’re in a production environment where you update the tools often.

mzp

Drop

The drop command is used to run a single maxscript when the mzp file is dropped into the viewport. This script should handle any 3ds Max functions you need to happen on installation.

My dropscript here is used to fileIn the main script so that any buttons or shortcuts associated with the macro script are updated. The user is then informed that this has worked. If the script couldn’t be ran because of an error, the user is notified.

There’s not a lot that can go wrong at this stage unless you’ve set your directories or treeCopies up wrong, but it is best practice to add try catches in there to avoid any possibly of silent error. Something as simple as “its broken, contact your tech artist” is infinitely better than things not working without the user’s knowledge.

try
(
fileIn “myMZPDistro.mcr”
MessageBox(“Succesfully Installed Some Tools!”)
)
catch
(
MessageBox(“Something went wrong. Please contact Amy.”)
)

Clearing Temporary Files

Clearing temp is important as by default scripts are stored in temp when the mzp is run. We never want to run scripts from a temporary directory, as these may be cleared. Instead copy scripts into a suitable directory, like $maxData, then use the command:

clear temp on MAX exit

Packaging it Up

Once you’ve created  your .run file and dropscript, its as simple as organising the files into a structure that works for you, then selecting the scripts folder and the .run file, right clicking and selecting Send To > Compressed Zip File (or making the zip file in your program of choice).

Once that’s done, make sure you don’t have file extensions hidden by going to File > Change Folder and Search Options in a windows explorer window, then unticking Hide Extensions For Known File Types on the View Tab.

Capture2

After that, press rename on your zip file, then change zip to mzp. Drag it into a 3ds max viewport, and you’re done!

 

 

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s