Thursday, July 10, 2014

Art of creating custom installers for your maxscripts. pt.1

3dsmax is a great application with great features. Arguably its greatest strength is ease of adding more features to it via plugins and scripts written with its inbuilt language- maxscript and, C++. Recently, Autodesk took this ability of making max even bigger and better via programming, to the next level; with Integration of python scripting. While its new, max based python scripted plugins are rare, scripts, written with its native language (as I mentioned earlier, maxscript) is still the most popular way of expanding max (among the ordinary users).

And the other great thing about these scripts is the ease of adding them to 3dsmax. Most of the time, if the script is independent, that it doesn’t need any external resources to run (ex: icons, settings stored in INI files) it’s just a matter of dragging and dropping the script on to max window. And for the scripts that have dependency on external resources, max have another solution, a specially prepared zip archive with a modified extension named .mzp.  It gives the developer the ability to archive the script and its dependence on to a one mzp file and distribute it easily. And on the other end, end user just have to drag and drop the mzp file on to their max window, as they did with an independent script, and contents of the .mzp gets extracted to the right locations and, script gets added to their package easily.

If we look closely, what is happening inside a mzp file, we can see it’s just an ordinary zip file, but with guidance to its extraction in a special file called “mzp.run” . In other words, anyone can create these self-extracting script packages, with a software that can create zip archives, and simple knowledge of how to code this “mzp.run” file.

As a fresh coder, the best way to improve coding is by making people use your code and give feedback; in other words, distribute them among people who are willing to use them and evaluate them.
So making scripts easy to install, run and of course- easy to uninstall is an essential part as I see. .mzp format does a decent job in installing and running scripts, but when it comes to uninstalling, mzp with default instructions doesn't help at all.

So the options are to create .exe installer for our scripts using third party software or go for a custom installer coded in maxscript.

First option, an exe installer is surely not the best solution here. Though it is the best solution for commercial plugins that may require special runtime environments or license services installed, here when it comes to just intermediate or simple level scripts that may be independent or depending on few external resources, the best solution is to go for a custom installer, coded in maxscript.

So I started writing a one. The plan is to archive the custom installer inside a .mzp file and when the mzp file is dragged and dropped to the max window, it extracts all the contents to 3ds Max temp folder, and run the custom installer script- and custom installer takes the task from there, presenting the user an interface to choose to install or uninstall the script.

With the next post on this topic, we will look in to a structure for this custom installer.

No comments:

Post a Comment