From 0cd7b6c60d1d1f60e70090e06ac985a402bbef36 Mon Sep 17 00:00:00 2001 From: Bastien Montagne <montagne29@wanadoo.fr> Date: Sun, 18 Aug 2013 15:16:51 +0000 Subject: [PATCH] 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. --- io_import_images_as_planes.py | 11 +++-------- texture_paint_layer_manager.py | 8 ++++++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/io_import_images_as_planes.py b/io_import_images_as_planes.py index 1981737ae..269de1bfd 100644 --- a/io_import_images_as_planes.py +++ b/io_import_images_as_planes.py @@ -453,15 +453,10 @@ class IMPORT_OT_image_to_plane(Operator, AddObjectHelper): 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 - - if filepath_rel is not None: - image.filepath = filepath_rel + pass def set_texture_options(self, context, texture): texture.image.use_alpha = self.use_transparency diff --git a/texture_paint_layer_manager.py b/texture_paint_layer_manager.py index dd8c3a054..0a4e23a5e 100644 --- a/texture_paint_layer_manager.py +++ b/texture_paint_layer_manager.py @@ -559,12 +559,16 @@ def save_painted(ts): 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 -- GitLab