Build an mzp maxscript in 3dsMax

When working with large scripts in 3dsMax it’s very practical to split the project up in multiple files. Done correctly this loosely resembles an object-oriented approach. Something that maxscript doesn’t really support. While working with multiple files is easier than with a single large one, publishing them is more work. This script helps with that.

I like to publish my scripts as an mzp-file. This is a self-extracting zip-file built for 3dsMax. Within an mzp-file you can bundle scriptfiles, art,presets or other files and link special actions which are executed upon installation. Building such a file needs some manual work however. It’s also very error-prone. I always have to check three times if everything is in place and have to edit my mzp-file after each try. This takes a lot of time and is frustrating. The mzpBuilder creates an mzp-file based on an ini-file you can fill in yourself. It also creates the run-file based on the data in the ini-file.Read more about the mzp-file in the maxscript documentation.

Using the ini-file makes the building process more consistent and a lot quicker. My script covers a small portion of the features of the mzp-files, but it’s enough for me at the moment. I might expand upon this if needed.

Check out the project on github or download it directly.

Alternatives

there are alternatives to this script: scriptbuilder and package script. They’re both on scriptspot. Both scripts combine multiple scriptfiles into a single one. What you end up with is a single scritpfile which is easy to distribute. It’s not the same as my tool however. The mzp-builder does combine the files in a single installer but it doesn’t touch the scripts themselves. The alternatives only support scriptfiles whereas the mzpbuilder also can include presets, art and whatever file you want to include.

Example

This example shows how I use the mzpBuilder with my sketchfab script. The sketchfab script uses many files, such as scripts, art and presets. In this case I’ve added the ini-file and resulting mzp.run-file below

Ini-file

[Header]
name=Sketchfab
description=Klaas Nienhuis Scripts
version=7
[config]
sourcerootpath=N:GitHubsketchfab
runfilepath=N:GitHubsketchfabInstallfiles
buildfilename=SketchfabPublisher
buildfilepath=N:GitHubsketchfabBuild
[Source]
1=scriptfilessketchfab.ms
2=scriptfilessketchfab_dae.ms
3=scriptfilessketchfab_errorHandling.ms
4=scriptfilessketchfab_gui.ms
5=scriptfilessketchfab_htmlPost.ms
6=scriptfilessketchfab_multithread.ms
7=scriptfilessketchfab_obj.ms
8=scriptfilessketchfab_rolloutFunctions.ms
9=scriptfilessketchfab_token.ms
10=scriptfilessketchfab_zip.ms
11=artsketchfabBanner_007.jpg
12=artsketchfab_16i.bmp
13=artsketchfab_24i.bmp
14=artsketchfab_24i.ico
15=installfilesKlaasNienhuis_Sketchfab_Install.ms
16=presetsobj_preset_sketchfab.ini
17=presetsopencollada_preset_sketchfab.ini
[Destination]
1=$userScriptsKlaasToolsSketchfabscriptfiles
2=$userScriptsKlaasToolsSketchfabscriptfiles
3=$userScriptsKlaasToolsSketchfabscriptfiles
4=$userScriptsKlaasToolsSketchfabscriptfiles
5=$userScriptsKlaasToolsSketchfabscriptfiles
6=$userScriptsKlaasToolsSketchfabscriptfiles
7=$userScriptsKlaasToolsSketchfabscriptfiles
8=$userScriptsKlaasToolsSketchfabscriptfiles
9=$userScriptsKlaasToolsSketchfabscriptfiles
10=$userScriptsKlaasToolsSketchfabscriptfiles
11=$userScriptsKlaasToolsSketchfab
12=$userIcons
13=$userIcons
14=$userIcons
15=$userScriptsKlaasToolsSketchfab
16=$userScriptsKlaasToolsSketchfab
17=$userScriptsKlaasToolsSketchfab
[DropIndices]
1=15
[RunIndices]
1=15

Note how the paths of the sourcefiles are all described relative to the rootpath. The script assumes a common root. You can’t take sourcefiles from all over the place. They need to have some structure, i.e. a common root. The destinations however can be totally random, whatever your script needs to function. It’s advisable to use 3dsMax system-paths. these start with the $-sign. they mark locations relative to the max-profile or max-installation on the client-machine.
Also note the runindices are being executed in the order they’re listed in the ini-file. So first script 16 is executed (the macro), then number 15 is executed (the welcome message).

mzp.run file

name "Sketchfab"
description "Klaas Nienhuis Scripts"
version 7

copy "scriptfilessketchfab.ms" to "$userScriptsKlaasToolsSketchfabscriptfiles"
copy "scriptfilessketchfab_dae.ms" to "$userScriptsKlaasToolsSketchfabscriptfiles"
copy "scriptfilessketchfab_errorHandling.ms" to "$userScriptsKlaasToolsSketchfabscriptfiles"
copy "scriptfilessketchfab_gui.ms" to "$userScriptsKlaasToolsSketchfabscriptfiles"
copy "scriptfilessketchfab_htmlPost.ms" to "$userScriptsKlaasToolsSketchfabscriptfiles"
copy "scriptfilessketchfab_multithread.ms" to "$userScriptsKlaasToolsSketchfabscriptfiles"
copy "scriptfilessketchfab_obj.ms" to "$userScriptsKlaasToolsSketchfabscriptfiles"
copy "scriptfilessketchfab_rolloutFunctions.ms" to "$userScriptsKlaasToolsSketchfabscriptfiles"
copy "scriptfilessketchfab_token.ms" to "$userScriptsKlaasToolsSketchfabscriptfiles"
copy "scriptfilessketchfab_zip.ms" to "$userScriptsKlaasToolsSketchfabscriptfiles"
copy "artsketchfabBanner_007.jpg" to "$userScriptsKlaasToolsSketchfab"
copy "artsketchfab_16i.bmp" to "$userIcons"
copy "artsketchfab_24i.bmp" to "$userIcons"
copy "artsketchfab_24i.ico" to "$userIcons"
copy "installfilesKlaasNienhuis_Sketchfab_Install.ms" to "$userScriptsKlaasToolsSketchfab"
copy "presetsobj_preset_sketchfab.ini" to "$userScriptsKlaasToolsSketchfab"
copy "presetsopencollada_preset_sketchfab.ini" to "$userScriptsKlaasToolsSketchfab"

drop $userScriptsKlaasToolsSketchfabKlaasNienhuis_Sketchfab_Install.ms

run $userScriptsKlaasToolsSketchfabKlaasNienhuis_Sketchfab_Install.ms

clear temp on MAX exit

Before I normally created these mzp.run files by hand. Now I have my builder do it! What a relief.

3 Comments

Join the discussion and tell us your opinion.

  • 2020-07-07 at 19:33

    Wow,is it some magic? Useful for some dumb like me to package my scripts into one mzp file looks promising and saving tons of time learning dos command

  • 2020-11-11 at 11:30

    Error: boolean class
    ” encryptscripts = GetINISetting theIniFile “Encrypt” “encryptscripts” as booleanclass ”

    I m using 3dsmax 2018 64 bit
    i need help. I want to make mzpbuild.

    thnx

    • 2020-11-19 at 07:47
      In reply to: Fatih gumus

      Hi Fatih, it seems as if you don’t have an “encryptscripts” key in your ini-file. Here you can see the expected structure of the ini-file https://github.com/klaasnienhuis/mzpBuilder

Leave a reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.