py api. bpy.utils.relpath() function.

This commit is contained in:
2010-04-21 09:27:36 +00:00
parent 0430572dee
commit 6a5c036304

View File

@@ -205,12 +205,30 @@ def load_scripts(reload_scripts=False, refresh_scripts=False):
def expandpath(path):
"""
Returns the absolute path relative to the current blend file using the "//" prefix.
"""
if path.startswith("//"):
return _os.path.join(_os.path.dirname(_bpy.data.filename), path[2:])
return path
def relpath(path, start=None):
"""
Returns the path relative to the current blend file using the "//" prefix.
:arg start: Relative to this path, when not set the current filename is used.
:type start: string
"""
if not path.startswith("//"):
if start is None:
start = _os.path.dirname(_bpy.data.filename)
return "//" + _os.path.relpath(path, start)
return path
_unclean_chars = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, \
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, \
35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 46, 47, 58, 59, 60, 61, 62, 63, \