[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4679] trunk/py/scripts/addons: More " relpath" try/except protection...

Bastien Montagne montagne29 at wanadoo.fr
Sun Aug 18 17:16:51 CEST 2013


Revision: 4679
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4679
Author:   mont29
Date:     2013-08-18 15:16:51 +0000 (Sun, 18 Aug 2013)
Log Message:
-----------
More "relpath" try/except protection...

Note: import gimp image also would need it, but it would anyway need a good cleanup (handling of paths is ugly), so did not bothered with it for now.

Modified Paths:
--------------
    trunk/py/scripts/addons/io_import_images_as_planes.py
    trunk/py/scripts/addons/texture_paint_layer_manager.py

Modified: trunk/py/scripts/addons/io_import_images_as_planes.py
===================================================================
--- trunk/py/scripts/addons/io_import_images_as_planes.py	2013-08-17 22:21:17 UTC (rev 4678)
+++ trunk/py/scripts/addons/io_import_images_as_planes.py	2013-08-18 15:16:51 UTC (rev 4679)
@@ -453,16 +453,11 @@
         image.use_fields = self.use_fields
 
         if self.relative:
-            # can't always find the relative path
-            # (between drive letters on windows)
-            try:
-                filepath_rel = bpy.path.relpath(image.filepath)
+            try:  # can't always find the relative path (between drive letters on windows)
+                image.filepath = bpy.path.relpath(image.filepath)
             except ValueError:
-                filepath_rel = None
+                pass
 
-            if filepath_rel is not None:
-                image.filepath = filepath_rel
-
     def set_texture_options(self, context, texture):
         texture.image.use_alpha = self.use_transparency
         texture.image_user.use_auto_refresh = self.use_auto_refresh

Modified: trunk/py/scripts/addons/texture_paint_layer_manager.py
===================================================================
--- trunk/py/scripts/addons/texture_paint_layer_manager.py	2013-08-17 22:21:17 UTC (rev 4678)
+++ trunk/py/scripts/addons/texture_paint_layer_manager.py	2013-08-18 15:16:51 UTC (rev 4679)
@@ -559,12 +559,16 @@
                         name = name +'.tga' 
                         
                     bpy.context.scene.render.image_settings.color_mode = 'RGBA'                          
-                    fp =bpy.path.abspath('//textures' + sep + name)
+                    fp = bpy.path.abspath('//textures' + sep + name)
                     try:
                         i.save_render(fp)
                         i.source = 'FILE'
                         if bpy.context.user_preferences.filepaths.use_relative_paths:
-                            i.filepath = bpy.path.relpath(fp) 
+                            # can't always find the relative path (between drive letters on windows)
+                            try:
+                                i.filepath = bpy.path.relpath(fp)
+                            except ValueError:
+                                i.filepath = fp
                         else:
                             i.filepath = fp
                         i.name = name



More information about the Bf-extensions-cvs mailing list