diff --git a/io_scene_fbx/import_fbx.py b/io_scene_fbx/import_fbx.py index b386e47a9451a2a55348e37560e505176e7ccbf1..22a4279dce5a88f1b09c33193cc104e6b42731e9 100644 --- a/io_scene_fbx/import_fbx.py +++ b/io_scene_fbx/import_fbx.py @@ -828,6 +828,17 @@ def blen_read_light(fbx_tmpl, fbx_obj, global_scale): return lamp +def is_ascii(filepath, size): + with open(filepath, 'r', encoding="utf-8") as f: + try: + f.read(size) + return True + except UnicodeDecodeError: + pass + + return False + + def load(operator, context, filepath="", global_matrix=None, use_cycles=True, @@ -843,6 +854,11 @@ def load(operator, context, filepath="", import os from . import parse_fbx + # detect ascii files + if is_ascii(filepath, 24): + operator.report({'ERROR'}, "ASCII FBX files are not supported %r" % filepath) + return {'CANCELLED'} + try: elem_root, version = parse_fbx.parse(filepath) except: