From: Mikko Rasa Date: Sun, 28 Mar 2021 09:47:29 +0000 (+0300) Subject: Fix exporting of materials without any textures X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=658df70cfc632e9f931b178ad7fd176c923b63a9;p=libs%2Fgl.git 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. --- 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