New Addon: Import Autodesk .max #105013

Closed
Sebastian Sille wants to merge 136 commits from (deleted):nrgsille-import_max into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Showing only changes of commit ab6139b6a4 - Show all commits

View File

@ -90,12 +90,12 @@ NOSTREAM = 0xFFFFFFFF # (-1) unallocated directory entry
UNKNOWN_SIZE = 0x7FFFFFFF UNKNOWN_SIZE = 0x7FFFFFFF
MIN_FILE_SIZE = 1536 MIN_FILE_SIZE = 1536
STGTY_EMPTY = 0 #: empty directory entry STGTY_EMPTY = 0 # empty directory entry
STGTY_STORAGE = 1 #: element is a storage object STGTY_STORAGE = 1 # element is a storage object
STGTY_STREAM = 2 #: element is a stream object STGTY_STREAM = 2 # element is a stream object
STGTY_LOCKBYTES = 3 #: element is an ILockBytes object STGTY_LOCKBYTES = 3 # element is an ILockBytes object
STGTY_PROPERTY = 4 #: element is an IPropertyStorage object STGTY_PROPERTY = 4 # element is an IPropertyStorage object
STGTY_ROOT = 5 #: element is a root storage STGTY_ROOT = 5 # element is a root storage
VT_EMPTY=0; VT_NULL=1; VT_I2=2; VT_I4=3; VT_R4=4; VT_R8=5; VT_CY=6; VT_EMPTY=0; VT_NULL=1; VT_I2=2; VT_I4=3; VT_R4=4; VT_R8=5; VT_CY=6;
VT_DATE=7; VT_BSTR=8; VT_DISPATCH=9; VT_ERROR=10; VT_BOOL=11; VT_DATE=7; VT_BSTR=8; VT_DISPATCH=9; VT_ERROR=10; VT_BOOL=11;
@ -226,7 +226,7 @@ class MaxStream(io.BytesIO):
def __init__(self, fp, sect, size, offset, sectorsize, fat, filesize): def __init__(self, fp, sect, size, offset, sectorsize, fat, filesize):
unknown_size = False unknown_size = False
if size == UNKNOWN_SIZE: if size == UNKNOWN_SIZE:
size = len(fat)*sectorsize size = len(fat) * sectorsize
unknown_size = True unknown_size = True
nb_sectors = (size + (sectorsize-1)) // sectorsize nb_sectors = (size + (sectorsize-1)) // sectorsize
@ -411,7 +411,7 @@ class ImportMaxFile:
else: else:
mode = 'rb' mode = 'rb'
self.fp = open(filename, mode) self.fp = open(filename, mode)
filesize=0 filesize = 0
self.fp.seek(0, os.SEEK_END) self.fp.seek(0, os.SEEK_END)
try: try:
filesize = self.fp.tell() filesize = self.fp.tell()
@ -568,22 +568,6 @@ class ImportMaxFile:
sectorsize=self.sectorsize, fat=self.fat, sectorsize=self.sectorsize, fat=self.fat,
filesize=self._filesize) filesize=self._filesize)
def _list(self, files, prefix, node, streams=True, storages=False):
prefix = prefix + [node.name]
for entry in node.kids:
if entry.entry_type == STGTY_STORAGE:
if storages:
files.append(prefix[1:] + [entry.name])
self._list(files, prefix, entry, streams, storages)
elif entry.entry_type == STGTY_STREAM:
if streams:
files.append(prefix[1:] + [entry.name])
def listdir(self, streams=True, storages=False):
files = []
self._list(files, [], self.root, streams, storages)
return files
def _find(self, filename): def _find(self, filename):
if isinstance(filename, str): if isinstance(filename, str):
filename = filename.split('/') filename = filename.split('/')
@ -666,7 +650,7 @@ class ImportMaxFile:
value = stream[offset + 8:offset + 8 + count] value = stream[offset + 8:offset + 8 + count]
elif property_type == VT_LPWSTR: elif property_type == VT_LPWSTR:
count = i32(stream, offset + 4) count = i32(stream, offset + 4)
value = self._decode_utf16_str(stream[offset + 8:offset + 8 + count*2]) value = self._decode_utf16_str(stream[offset + 8:offset + 8 + count * 2])
elif property_type == VT_FILETIME: elif property_type == VT_FILETIME:
value = int(i32(stream, offset + 4)) + (int(i32(stream, offset + 8)) << 32) value = int(i32(stream, offset + 4)) + (int(i32(stream, offset + 8)) << 32)
if convert_time and property_id not in no_conversion: if convert_time and property_id not in no_conversion: