Zip files in 3ds Max

You can zip files in 3dsMax with maxscript. 3ds Max comes with a program called maxzip. This application is also used by 3ds Max itself when archiving files. So why not use this small piece of software to zip your own files?

Credits

I’ve taken much of the following script from Rene Baca over at cgTalk. I’ve edited the scripts slightly, added some error-trapping and added a lot of comments. This should make it easier for any scripter to to figure out what the script is doing.

Multithreading

A new feature I’m just implementing in some of my scripts is multithreading. It’s not always very useful and definitely not error-free. For zipping larger files however it’s very useful. I’ve added the option to use the zip-method singlethreaded or multithreaded. For more info in multithreading, check out the article by Lonerobot on this topic.

Command

It’s practical to set up a commandstring as the command is executed with hiddendoscommand. Setting up the string is pretty flexible. In my experience you can only zip stuff to and from mapped drives.

        util = (getDir #maxRoot) + "maxzip.exe" --the zipping-program
        zipFile = targetFolderPath + "zippy.zip"
        sourceFile = someFile --a single file to zip   
        cmd = "" as stringStream --set up a zipping-command
        format ""%" "%" "%"" util zipFile sourceFile to:cmd --the commandstring
        (hiddendosCommand cmd exitcode:&exitcode) --EXECUTE THE ZIPPING

Here a single file is zipped. The struct works with multiple files and recursively searches a root-folder.

Download zip script

Leave a Reply

* Will not be published