From 658df70cfc632e9f931b178ad7fd176c923b63a9 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 28 Mar 2021 12:47:29 +0300 Subject: [PATCH] Fix exporting of materials without any textures If a generator expression produces no items, trying to access __next__() produces a StopIteration exception. It's better to create a list so we can check if it's empty. --- blender/io_mspgl/export_material.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/blender/io_mspgl/export_material.py b/blender/io_mspgl/export_material.py index d69389cc..4d2fe074 100644 --- a/blender/io_mspgl/export_material.py +++ b/blender/io_mspgl/export_material.py @@ -73,11 +73,11 @@ class MaterialExporter: if ss: st.sub.append(ss) if self.use_textures: - first_tex = (p.texture for p in material.properties if p.texture).__next__() - if first_tex and not first_tex.default_filter: + textures = [p.texture for p in material.properties if p.texture] + if textures and not textures[0].default_filter: from .export_texture import SamplerExporter sampler_export = SamplerExporter() - st.sub.append(mat_res.create_reference_statement("sampler", resources[sampler_export.get_sampler_name(first_tex)])) + st.sub.append(mat_res.create_reference_statement("sampler", resources[sampler_export.get_sampler_name(textures[0])])) mat_res.statements.append(st) return mat_res -- 2.43.0