[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4461] trunk/py/scripts/addons/ io_scene_vrml2/export_vrml2.py: move image guessing function into bpy_extras

Campbell Barton ideasman42 at gmail.com
Wed Apr 10 13:44:30 CEST 2013


Revision: 4461
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4461
Author:   campbellbarton
Date:     2013-04-10 11:44:30 +0000 (Wed, 10 Apr 2013)
Log Message:
-----------
move image guessing function into bpy_extras

Modified Paths:
--------------
    trunk/py/scripts/addons/io_scene_vrml2/export_vrml2.py

Modified: trunk/py/scripts/addons/io_scene_vrml2/export_vrml2.py
===================================================================
--- trunk/py/scripts/addons/io_scene_vrml2/export_vrml2.py	2013-04-09 09:02:02 UTC (rev 4460)
+++ trunk/py/scripts/addons/io_scene_vrml2/export_vrml2.py	2013-04-10 11:44:30 UTC (rev 4461)
@@ -22,7 +22,9 @@
 import bpy_extras
 import bmesh
 import os
+from bpy_extras import object_utils
 
+
 def save_bmesh(fw, bm,
                use_color, color_type, material_colors,
                use_uv, uv_image,
@@ -147,26 +149,6 @@
     fw('}\n')  # end 'Shape'
 
 
-def detect_default_image(obj, bm):
-    tex_layer = bm.faces.layers.tex.active
-    if tex_layer is not None:
-        for f in bm.faces:
-            image = f[tex_layer].image
-            if image is not None:
-                return image
-    for m in obj.data.materials:
-        if m is not None:
-            # backwards so topmost are highest priority
-            for mtex in reversed(m.texture_slots):
-                if mtex and mtex.use_map_color_diffuse:
-                    texture = mtex.texture
-                    if texture and texture.type == 'IMAGE':
-                        image = texture.image
-                        if image is not None:
-                            return image
-    return None
-
-
 def save_object(fw, global_matrix,
                 scene, obj,
                 use_mesh_modifiers,
@@ -220,7 +202,7 @@
     if use_uv:
         if bm.loops.layers.uv.active is None:
             use_uv = False
-        uv_image = detect_default_image(obj, bm)
+        uv_image = object_utils.object_image_guess(obj, bm=bm)
         if uv_image is None:
             use_uv = False
 



More information about the Bf-extensions-cvs mailing list