technical architecture.

python based model/texture/matlib browser

by on Jul.24, 2009, under Uncategorized

This was a learning experiment a few months back that showed some promise, and turned into a pretty useful script, I debated passing it around due to its current ‘raw’ness, but it has already been very helpful here, and I think some feedback may motivate me to tighten it up some more!

pyAssetbrowser Screenshot


Setting it up

You pick a ‘Root Directory’ by editing the settings.ini file and changing the “rootPath=X:\\Model_Library\\” to match up with your chosen path. ex: if your model library is on C:\Assets, then you will make the settings.ini file read as: “rootPath=C:\\Assets\\” every directory under this ‘root’ directory will show up in the Treeview interface on the left hand side.

(and here comes the part that made me wary of distributing it)

For the connection with 3dsmax to work, python needs to know which version of max to connect to when ‘Max.Application’ is invoked! the cleanest way to do this is to just run Adams script:, this should work for most people! the cases I’ve found where it doesn’t work, are where there are more restrictive windows user permissions, in which case it may be required to manually do this. I’ve included a couple example .reg files that can connect to max 2008 / 2009, all that’s needed to suit them to your particular installation is to edit the paths under the LocalServer32 reg key for your particular max version.

On the 3dsmax side of things, there are a couple scripts included, the script is a Struct including some simple functions for things like importing, merging, converting to vrmesh, billboarding image maps, collapsing, re-linking maps using a few stripped down bits of modified code from an older version of ColinSenner‘s Relink Bitmaps script

File Structure

for the browser to work right as is, there are a few ‘format’ type issues that are needed to make it even remotely useful.

  • To use it as a Model Library:
    • A directory that includes .Max files.
    • If there is a .JPG file with the same name as the .MAX file, then it will be displayed as the thumbnail for the item, if there is no preview jpg the maxfile will show with a 3dsmax icon.

The material library setup is kind of strange, but its modeled somewhat after easily adding items from the site, by just unzipping the library and ensuring that the directory has the same name as the thumbnail.

  • Material Library:
    • A Directory of .JPG thumbnails (Any size)
    • In the same directory, a Folder with the same name as the .JPG thumbnail
    • in the named folder (Yea, this gets a bit messy) a 3dsmax .mat material library file (Any name), and any textures required
  • Billboard/texture Library:
    • A directory of images, Most formats should work, Tiff’s wont show thumbnails due to some open source licensing silliness with PIL i believe.
    • One of the good things here, is that it can build a thumbnail list very very fast. not quite picasa fast, but far quicker than explorer does.

I’m sure there’ll be many issues, so call it a beta, and let me know if anyone has feedback!

I’m including the source also, as 90% of it is all bits and pieces of other peoples work!

A little source info

  • I compiled with python 2.5
  • the awesome ThumbnailCtrl from Andrea Gavanna
    • I did some *very* slight modifications on it to allow it to show .max files as an icon
  • used PIL 1.1.6+
  • Requires pyWin32 v212+ for the COM bridging to talk to 3dsMax
  • Interface in wxwidgets, using wxPython 2.8
  • ‘lazy’ directory treeview from here
  • exe compiled with py2exe 0.6.9

Some things that currently aren’t possible, but are obvious additions:

Multiple Root items in the treeview to allow for the fact of the various libraries to be in seperate locations/drives…

This can be done, but is a bit of a pain in the arse, how you would do it would be to create a virtual root, which is hidden (As the current root item is now) and add in your sub items below it with specific paths, the trick is just to adjust the path sent to the thumbnail control to account for the ‘virtual’ root. Not difficult, but possibly a little time consuming, so its been shelved unless someone wants to buy me a beer or two to polish it up 🙂

There is currently no way to retrieve the explorer bitmap thumbnails for .max files through python/pywin32, there is a few hints at there being possible workarounds and ideas that could work on Mark Hammond’s mailing list, but most of the talk about this is several years stale! any thoughts on this from the python heads would be more than welcome!

there are a few errors that pop up after closing but they dont affect usage currently.

3 Comments for this entry

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!