Showing posts with label Art of creating custom installers for your maxscripts. Show all posts
Showing posts with label Art of creating custom installers for your maxscripts. Show all posts

Monday, August 18, 2014

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

A common custom maxscript installer can use basic maxscript commands such as getdir , copyfile, deletefile. You can get an idea about how max can interact with external files, if you look up “external file commands” in maxscript reference. As I mentioned earlier, it’s best to hook up the custom installer script with a self-extracting max zip (.mzp) file.
As soon as you drag and drop an .mzp file in to max window, max will extract its content to its temp directory. And start following the instructions we set inside “mzp.run” file.  Actually, you can just install your package with only using the instructions inside this “mzp.run” file, but as I mentioned in the early blog post, you will not be able to present your user a GUI, possibly with uninstall function and installation progress and etc.
So let’s begin with the folder structure of the archive. We will be using separate folders for each type of elements we hope to install. Separate directories for icons, macro scripts, scripts and other common elements that we can find in a common 3ds Max script package.
In context, the functioning of the installer script is this simple;

  • It will get all the path variables that it needs to place/ install each type of elements that are related to the script.
  • Check if the script is already installed and create and set the GUI accordingly, with options for the user to install/uninstall
  • If user press install, copies/ installs the script elements to corresponding paths.
  • If user press uninstall, removes all the script elements from the corresponding paths.
  • Give visual feedback/ notifications on the installation/ uninstallation process.

As a flow chart, we can put it like this;

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.