Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Duroure <julien.duroure@gmail.com>2019-01-23 23:08:22 +0300
committerJulien Duroure <julien.duroure@gmail.com>2019-01-23 23:08:49 +0300
commitacf3bcb5b5c763edb83f511ecf7873a04ae23f96 (patch)
tree06e50fb7201d169cc313f7bf9fe02b98d9dad06e /io_scene_gltf2/blender/imp/gltf2_blender_image.py
parent49c1b409286937d00a63fbf4cfb1f820a75a80c0 (diff)
glTF importer: fix bug when texture file is not found
Diffstat (limited to 'io_scene_gltf2/blender/imp/gltf2_blender_image.py')
-rwxr-xr-xio_scene_gltf2/blender/imp/gltf2_blender_image.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_image.py b/io_scene_gltf2/blender/imp/gltf2_blender_image.py
index ca1eb626..d51c463e 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_image.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_image.py
@@ -43,7 +43,7 @@ class BlenderImage():
if isfile(join(dirname(gltf.filename), pyimage.uri)):
return True, join(dirname(gltf.filename), pyimage.uri), basename(join(dirname(gltf.filename), pyimage.uri))
else:
- pyimage.gltf.log.error("Missing file (index " + str(img_idx) + "): " + pyimage.uri)
+ gltf.log.error("Missing file (index " + str(img_idx) + "): " + pyimage.uri)
return False, None, None
if pyimage.buffer_view is None:
@@ -89,13 +89,14 @@ class BlenderImage():
# Create a temp image, pack, and delete image
tmp_image = tempfile.NamedTemporaryFile(delete=False)
img_data, img_name = BinaryData.get_image_data(gltf, img_idx)
- tmp_image.write(img_data)
- tmp_image.close()
-
- blender_image = bpy.data.images.load(tmp_image.name)
- blender_image.pack()
- blender_image.name = img_name
- img.blender_image_name = blender_image.name
- blender_image['gltf_index'] = img_idx
- os.remove(tmp_image.name)
+ if img_name is not None:
+ tmp_image.write(img_data)
+ tmp_image.close()
+
+ blender_image = bpy.data.images.load(tmp_image.name)
+ blender_image.pack()
+ blender_image.name = img_name
+ img.blender_image_name = blender_image.name
+ blender_image['gltf_index'] = img_idx
+ os.remove(tmp_image.name)