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

add check for reading ascii fbx files, was common annoyance that users are...

add check for reading ascii fbx files, was common annoyance that users are unaware that they try to import ascii files.
parent e8434f0e
Branches
Tags
No related merge requests found
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment