Notifications
Clear all

[Closed] Getting max thumbnail issue.

using of the OLE dll sounds me as a problem… i couldn’t find a clean way to distribute this DLL with my tools. so i’m using my own (honestly the over-thought the … you know)

Thanks for the rundown of how you do it. Do this approach work with x64 versions of max as well?

As for loading the OLE.interop.dll from the same folder as your assembly, try setting the copy local to true in the file properties in visual studio, I think that should make it work.

This thread is awesome, great work guys!

I was wondering if with the same method would be possible to get also the info present in the FileAssetMetaData2 stream like for example the used plugins. I`ve seen there is a specific method (OpenMAXStorageFile) in the SDK but its not working in C#.
Anyone has knowledge of that stream format ?

The FileAssetMetaData stream contains only path and type for each asset. To see which plugins are loaded you either have to parse the DllDirectory stream, which can be parsed following this guide, or you can parse the DocumentSummaryInformation stream, which is a structured storage (which is kinda tedious to parse). Both streams holds the filename of the plugin, but the first method also has a short description.

Hi Haavard,
Yes I meant the DocumentSummaryInformatio, sorry, my bad.
Anyway the post you linked it’s really useful, thank you!
I did not notice there was also the DllDirectory stream it seems easier to parse.

Thanks for pointing me to the right direction.

Has anyone successfully read the Max thumbnail using Python with the win32com and pythoncon modules? I can read the IPropertyStorageSet stuff off of a .max scene file and can get property IDs 2 (Title), 3(Subject), 4 (Author), 8 (user name), 12 (creation date), 13 (modify date), and 37 (version) to display their values. But ID 17, which I think is the thumbnail, generates an exception. It’s a TypeError exception with the description “Unsupported property type 0x47”. I can’t decide if this means that either win32com or pythoncon doesn’t have the necessary bits to read the CF_METADATA_FILE structure or if I need to code up something to get to it. Any help would be appreciated.

Can you post a working sample of what you got so far?

Sure!

import pythoncom
import sys
import win32com.storagecon

FMTID_UserDefinedProperties = '{F29F85E0-4FF9-1068-AB91-08002B27B3D9}'
FMTID_CustomDefinedProperties = '{D5CDD505-2E9C-101B-9397-08002B2CF9AE}'


def read_custom_properties(filename):
    if not pythoncom.StgIsStorageFile(filename):
        print 'The provided file does not contain any IPropertySetStorage data.'
        return

    flags = win32com.storagecon.STGM_READWRITE  | win32com.storagecon.STGM_SHARE_EXCLUSIVE
    stg = pythoncom.StgOpenStorage(filename, None, flags)

    try:
        property_set_storage = stg.QueryInterface(pythoncom.IID_IPropertySetStorage)
    except pythoncom.com_error:
        print 'No summary information available'
        return

    user_defined_property_set = property_set_storage.Open(FMTID_UserDefinedProperties, flags) #PyIPropertyStorage object
    udps_enum = user_defined_property_set.Enum() # PyIEnumSTATPROPSTG
    udp = udps_enum.Next(1) # argument is the number of records to get

    while udp:
        property_name = udp[0]

        try:
            property_value = user_defined_property_set.ReadMultiple((property_name[1],))
            print 'Property ID {0} = {1}'.format(property_name[1], property_value[0])

        except TypeError:
            print 'Property ID {0} cannot be read. The exception is: {1}'.format(property_name[1], sys.exc_info()[1])

        udp = udps_enum.Next(1)



if __name__ == '__main__':
    if len(sys.argv) < 2:
        print 'Please specify a filename'
    else:
        read_custom_properties(sys.argv[1])

I snooped around in the source code for pywin32 and found the method that throws the exception. Link to source. The method is PyObject_FromPROPVARIANT and does not support the VT_CF variant type. It is actually commented out from the method. I dont think it is hard to add support for it, but you would have to build the source yourself after modifying it.

Great Job!

Did you have some similar to Inventor files?

Thanks & regards,
Rui

Page 3 / 3