py api: bpy.path.abspath(), option to return relative to a path other then the current blend file.

This commit is contained in:
Campbell Barton 2011-01-15 20:35:31 +00:00
parent fd7b6519fd
commit 743182106f

@ -27,12 +27,15 @@ import bpy as _bpy
import os as _os
def abspath(path):
def abspath(path, start=None):
"""
Returns the absolute 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 path.startswith("//"):
return _os.path.join(_os.path.dirname(_bpy.data.filepath), path[2:])
return _os.path.join(_os.path.dirname(_bpy.data.filepath if start is None else start), path[2:])
return path