[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4635] trunk/py/scripts/addons/ io_import_images_as_planes.py: fix error when finding relative paths on windows.

Campbell Barton ideasman42 at gmail.com
Mon Jul 22 20:51:18 CEST 2013


Revision: 4635
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4635
Author:   campbellbarton
Date:     2013-07-22 18:51:17 +0000 (Mon, 22 Jul 2013)
Log Message:
-----------
fix error when finding relative paths on windows.

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

Modified: trunk/py/scripts/addons/io_import_images_as_planes.py
===================================================================
--- trunk/py/scripts/addons/io_import_images_as_planes.py	2013-07-21 07:30:06 UTC (rev 4634)
+++ trunk/py/scripts/addons/io_import_images_as_planes.py	2013-07-22 18:51:17 UTC (rev 4635)
@@ -453,8 +453,16 @@
         image.use_fields = self.use_fields
 
         if self.relative:
-            image.filepath = bpy.path.relpath(image.filepath)
+            # can't always find the relative path
+            # (between drive letters on windows)
+            try:
+                filepath_rel = bpy.path.relpath(image.filepath)
+            except ValueError:
+                filepath_rel = None
 
+            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



More information about the Bf-extensions-cvs mailing list