[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40923] trunk/blender/release/scripts/ modules: py api: bpy_extras.io_utils.path_reference() - added library argument so exporters get the paths of linked images right .
Campbell Barton
ideasman42 at gmail.com
Tue Oct 11 06:36:29 CEST 2011
Revision: 40923
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40923
Author: campbellbarton
Date: 2011-10-11 04:36:27 +0000 (Tue, 11 Oct 2011)
Log Message:
-----------
py api: bpy_extras.io_utils.path_reference() - added library argument so exporters get the paths of linked images right.
Modified Paths:
--------------
trunk/blender/release/scripts/modules/bpy/path.py
trunk/blender/release/scripts/modules/bpy_extras/io_utils.py
Modified: trunk/blender/release/scripts/modules/bpy/path.py
===================================================================
--- trunk/blender/release/scripts/modules/bpy/path.py 2011-10-11 04:30:04 UTC (rev 40922)
+++ trunk/blender/release/scripts/modules/bpy/path.py 2011-10-11 04:36:27 UTC (rev 40923)
@@ -268,7 +268,7 @@
def basename(path):
"""
- Equivalent to os.path.basename, but skips a "//" suffix.
+ Equivalent to os.path.basename, but skips a "//" prefix.
Use for Windows compatibility.
"""
Modified: trunk/blender/release/scripts/modules/bpy_extras/io_utils.py
===================================================================
--- trunk/blender/release/scripts/modules/bpy_extras/io_utils.py 2011-10-11 04:30:04 UTC (rev 40922)
+++ trunk/blender/release/scripts/modules/bpy_extras/io_utils.py 2011-10-11 04:36:27 UTC (rev 40923)
@@ -350,6 +350,7 @@
mode='AUTO',
copy_subdir="",
copy_set=None,
+ library=None,
):
"""
Return a filepath relative to a destination directory, for use with
@@ -372,12 +373,15 @@
:arg copy_set: collect from/to pairs when mode='COPY',
pass to *path_reference_copy* when exportign is done.
:type copy_set: set
+ :arg library: The library this path is relative to.
+ :type library: :class:`bpy.types.Library` or None
:return: the new filepath.
:rtype: string
"""
import os
is_relative = filepath.startswith("//")
- filepath_abs = os.path.normpath(bpy.path.abspath(filepath, base_src))
+ filepath_abs = bpy.path.abspath(filepath, base_src, library)
+ filepath_abs = os.path.normpath(filepath_abs)
if mode in {'ABSOLUTE', 'RELATIVE', 'STRIP'}:
pass
@@ -385,13 +389,12 @@
mode = 'RELATIVE' if is_relative else 'ABSOLUTE'
elif mode == 'AUTO':
mode = ('RELATIVE'
- if bpy.path.is_subdir(filepath, base_dst)
+ if bpy.path.is_subdir(filepath_abs, base_dst)
else 'ABSOLUTE')
elif mode == 'COPY':
+ subdir_abs = os.path.normpath(base_dst)
if copy_subdir:
- subdir_abs = os.path.join(os.path.normpath(base_dst), copy_subdir)
- else:
- subdir_abs = os.path.normpath(base_dst)
+ subdir_abs = os.path.join(subdir_abs, copy_subdir)
filepath_cpy = os.path.join(subdir_abs, os.path.basename(filepath))
More information about the Bf-blender-cvs
mailing list