[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32222] trunk/blender/release/scripts: bugfix [#24065] obj export (mtl image path)
Campbell Barton
ideasman42 at gmail.com
Fri Oct 1 07:19:59 CEST 2010
Revision: 32222
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32222
Author: campbellbarton
Date: 2010-10-01 07:19:40 +0200 (Fri, 01 Oct 2010)
Log Message:
-----------
bugfix [#24065] obj export (mtl image path)
Modified Paths:
--------------
trunk/blender/release/scripts/modules/bpy/path.py
trunk/blender/release/scripts/op/io_scene_obj/export_obj.py
Modified: trunk/blender/release/scripts/modules/bpy/path.py
===================================================================
--- trunk/blender/release/scripts/modules/bpy/path.py 2010-09-30 22:27:37 UTC (rev 32221)
+++ trunk/blender/release/scripts/modules/bpy/path.py 2010-10-01 05:19:40 UTC (rev 32222)
@@ -52,6 +52,17 @@
return path
+def is_subdir(path, directory):
+ """
+ Returns true if *path* in a subdirectory of *directory*.
+ Both paths must be absolute.
+ """
+ from os.path import normpath, normcase
+ path = normpath(normcase(path))
+ directory = normpath(normcase(directory))
+ return path.startswith(directory)
+
+
def clean_name(name, replace="_"):
"""
Returns a name with characters replaced that may cause problems under various circumstances, such as writing to a file.
Modified: trunk/blender/release/scripts/op/io_scene_obj/export_obj.py
===================================================================
--- trunk/blender/release/scripts/op/io_scene_obj/export_obj.py 2010-09-30 22:27:37 UTC (rev 32221)
+++ trunk/blender/release/scripts/op/io_scene_obj/export_obj.py 2010-10-01 05:19:40 UTC (rev 32222)
@@ -40,12 +40,16 @@
def copy_image(image):
fn = bpy.path.abspath(image.filepath)
+ fn = os.path.normpath(fn)
fn_strip = os.path.basename(fn)
+
if copy_images:
rel = fn_strip
fn_abs_dest = os.path.join(dest_dir, fn_strip)
if not os.path.exists(fn_abs_dest):
shutil.copy(fn, fn_abs_dest)
+ elif bpy.path.is_subdir(fn, dest_dir):
+ rel = os.path.relpath(fn, dest_dir)
else:
rel = fn
More information about the Bf-blender-cvs
mailing list