[Bf-extensions-cvs] [2edd24a4] master: Fix T51503 Added support for Cycles image textures

florianfelix noreply at git.blender.org
Fri Sep 29 17:29:47 CEST 2017


Commit: 2edd24a4e6c5b77ddca88cbddaa581edf0d89e8b
Author: florianfelix
Date:   Fri Sep 29 17:11:31 2017 +0200
Branches: master
https://developer.blender.org/rBA2edd24a4e6c5b77ddca88cbddaa581edf0d89e8b

Fix T51503 Added support for Cycles image textures

===================================================================

M	io_online_sketchfab/pack_for_export.py

===================================================================

diff --git a/io_online_sketchfab/pack_for_export.py b/io_online_sketchfab/pack_for_export.py
index 16d38cca..e9fbde72 100644
--- a/io_online_sketchfab/pack_for_export.py
+++ b/io_online_sketchfab/pack_for_export.py
@@ -61,17 +61,31 @@ def prepare_assets(export_settings):
 
         for ob in bpy.data.objects:
             if ob.type == 'MESH':
+
                 for mat_slot in ob.material_slots:
-                    if not mat_slot.material:
-                        continue
-                    for tex_slot in mat_slot.material.texture_slots:
-                        if not tex_slot:
+                    #CYCLES RENDER
+                    if bpy.context.scene.render.engine == 'CYCLES':
+                        if not mat_slot.material:
+                            continue
+                        if not mat_slot.material.node_tree:
                             continue
-                        tex = tex_slot.texture
-                        if tex.type == 'IMAGE':
-                            image = tex.image
-                            if image is not None:
-                                images.add(image)
+                        imgnodes = [n for n in mat_slot.material.node_tree.nodes if n.type == 'TEX_IMAGE']
+                        for node in imgnodes:
+                            if node.image is not None:
+                                images.add(node.image)
+                    #BLENDER RENDER
+                    else:
+                        if not mat_slot.material:
+                            continue
+                        for tex_slot in mat_slot.material.texture_slots:
+                            if not tex_slot:
+                                continue
+                            tex = tex_slot.texture
+                            if tex.type == 'IMAGE':
+                                image = tex.image
+                                if image is not None:
+                                    images.add(image)
+
             if ((export_settings['models'] == 'SELECTION' and ob.type == 'MESH') or
                 (export_settings['lamps'] == 'SELECTION' and ob.type == 'LAMP')):



More information about the Bf-extensions-cvs mailing list