From 2570e9660f21862d00e1a7e0d78b33f741c21141 Mon Sep 17 00:00:00 2001
From: Campbell Barton <ideasman42@gmail.com>
Date: Mon, 22 Jul 2013 18:51:17 +0000
Subject: [PATCH] fix error when finding relative paths on windows.

---
 io_import_images_as_planes.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/io_import_images_as_planes.py b/io_import_images_as_planes.py
index f1bd5448d..1981737ae 100644
--- a/io_import_images_as_planes.py
+++ b/io_import_images_as_planes.py
@@ -453,7 +453,15 @@ class IMPORT_OT_image_to_plane(Operator, AddObjectHelper):
         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
-- 
GitLab