[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2416] trunk/py/scripts/addons/ render_povray/render.py: update to povray export

Campbell Barton ideasman42 at gmail.com
Tue Oct 11 06:12:14 CEST 2011


Revision: 2416
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2416
Author:   campbellbarton
Date:     2011-10-11 04:12:13 +0000 (Tue, 11 Oct 2011)
Log Message:
-----------
update to povray export
- use library paths for images.
- remove path searching code for images, if image paths are incorrect users should deal with this.
- rename splitHyphen --> string_strip_hyphen

Modified Paths:
--------------
    trunk/py/scripts/addons/render_povray/render.py

Modified: trunk/py/scripts/addons/render_povray/render.py
===================================================================
--- trunk/py/scripts/addons/render_povray/render.py	2011-10-10 15:53:33 UTC (rev 2415)
+++ trunk/py/scripts/addons/render_povray/render.py	2011-10-11 04:12:13 UTC (rev 2416)
@@ -105,38 +105,15 @@
     return image_mapBG
 
 
-def findInSubDir(filename, subdirectory=""):
-    pahFile = ""
-    if subdirectory:
-        path = subdirectory
-    else:
-        path = os.getcwd()
-    try:
-        for root, dirs, names in os.walk(path):
-            if filename in names:
-                pahFile = os.path.join(root, filename)
-        return pahFile
-    except OSError:
-        return ""
-
-
 def path_image(image):
-    import os
-    fn = bpy.path.abspath(image)
-    if not os.path.isfile(fn):
-        fn = findInSubDir(os.path.basename(fn), os.path.dirname(bpy.data.filepath))
-    fn = os.path.realpath(fn)
-    return fn
+    return bpy.path.abspath(image.filepath, library=image.library)
 
-##############end find image texture
+# end find image texture
+# -----------------------------------------------------------------------------
 
 
-def splitHyphen(name):
-    hyphidx = name.find("-")
-    if hyphidx == -1:
-        return name
-    else:
-        return name[:].replace("-", "")
+def string_strip_hyphen(name):
+    return name.replace("-", "")
 
 
 def safety(name, Level):
@@ -153,7 +130,7 @@
     except:
         prefix = ""
     prefix = "shader_"
-    name = splitHyphen(name)
+    name = string_strip_hyphen(name)
     if Level == 2:
         return prefix + name
     elif Level == 1:
@@ -221,7 +198,7 @@
     def uniqueName(name, nameSeq):
 
         if name not in nameSeq:
-            name = splitHyphen(name)
+            name = string_strip_hyphen(name)
             return name
 
         name_orig = name
@@ -229,7 +206,7 @@
         while name in nameSeq:
             name = "%s_%.3d" % (name_orig, i)
             i += 1
-        name = splitHyphen(name)
+        name = string_strip_hyphen(name)
         return name
 
     def writeMatrix(matrix):
@@ -867,8 +844,8 @@
             else:
                 name_orig = DEF_OBJ_NAME
                 dataname_orig = DEF_OBJ_NAME
-            name = splitHyphen(bpy.path.clean_name(name_orig))
-            dataname = splitHyphen(bpy.path.clean_name(dataname_orig))
+            name = string_strip_hyphen(bpy.path.clean_name(name_orig))
+            dataname = string_strip_hyphen(bpy.path.clean_name(dataname_orig))
 ##            for slot in ob.material_slots:
 ##                if slot.material != None and slot.link == 'OBJECT':
 ##                    obmaterial = slot.material
@@ -1061,7 +1038,7 @@
                 texturesAlpha = ""
                 for t in material.texture_slots:
                     if t and t.texture.type == 'IMAGE' and t.use and t.texture.image:
-                        image_filename = path_image(t.texture.image.filepath)
+                        image_filename = path_image(t.texture.image)
                         imgGamma = ""
                         if image_filename:
                             if t.use_map_color_diffuse:
@@ -1583,7 +1560,7 @@
                 # XXX No enable checkbox for world textures yet (report it?)
                 #if t and t.texture.type == 'IMAGE' and t.use:
                 if t and t.texture.type == 'IMAGE':
-                    image_filename = path_image(t.texture.image.filepath)
+                    image_filename = path_image(t.texture.image)
                     if t.texture.image.filepath != image_filename:
                         t.texture.image.filepath = image_filename
                     if image_filename != "" and t.use_map_blend:



More information about the Bf-extensions-cvs mailing list