Skip to content
Snippets Groups Projects
Commit e5af17eb authored by Campbell Barton's avatar Campbell Barton
Browse files

unique name exporting was broken, needed to export bytes.

parent 79c899da
Branches
Tags
No related merge requests found
......@@ -89,23 +89,24 @@ import struct
# So 3ds max can open files, limit names to 12 in length
# this is verry annoying for filenames!
name_unique = []
name_mapping = {}
name_unique = [] # stores str, ascii only
name_mapping = {} # stores {orig: byte} mapping
def sane_name(name):
name_fixed = name_mapping.get(name)
if name_fixed is not None:
return name_fixed
new_name = name[:12]
# strip non ascii chars
new_name_clean = new_name = name.encode("ASCII", "replace").decode("ASCII")[:12]
i = 0
while new_name in name_unique:
new_name = new_name[:-4] + '.%.3d' % i
new_name = new_name_clean + ".%.3d" % i
i+=1
# note, appending the 'str' version.
name_unique.append(new_name)
name_mapping[name] = new_name
name_mapping[name] = new_name = new_name.encode("ASCII", "replace")
return new_name
def uv_key(uv):
......@@ -167,7 +168,8 @@ class _3ds_string(object):
'''Class representing a zero-terminated string for a 3ds file.'''
__slots__ = ('value', )
def __init__(self, val):
self.value=val
assert(type(val) == bytes)
self.value = val
def get_size(self):
return (len(self.value)+1)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment