Page Menu
Home
Search
Configure Global Search
Log In
Files
F1794
sys_fullname_patch.txt
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Campbell Barton (campbellbarton)
Nov 13 2013, 1:00 PM
Size
3 KB
Subscribers
None
sys_fullname_patch.txt
View Options
Index: source/blender/python/api2_2x/Sys.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/Sys.c,v
retrieving revision 1.17
diff -u -p -r1.17 Sys.c
--- source/blender/python/api2_2x/Sys.c 9 Mar 2005 19:45:55 -0000 1.17
+++ source/blender/python/api2_2x/Sys.c 6 Apr 2005 04:30:37 -0000
@@ -31,12 +31,12 @@
*/
#include <BKE_utildefines.h>
+#include <DNA_scene_types.h> /* only need this to accsess current frame number os of 2005/04/06 */
#include <BLI_blenlib.h>
#include <PIL_time.h>
#include <Python.h>
#include <sys/stat.h>
#include "gen_utils.h"
-
#include "Sys.h"
/*****************************************************************************/
@@ -46,6 +46,7 @@ static PyObject *M_sys_basename( PyObjec
static PyObject *M_sys_dirname( PyObject * self, PyObject * args );
static PyObject *M_sys_join( PyObject * self, PyObject * args );
static PyObject *M_sys_splitext( PyObject * self, PyObject * args );
+static PyObject *M_sys_fullpath( PyObject * self, PyObject * args );
static PyObject *M_sys_makename( PyObject * self, PyObject * args,
PyObject * kw );
static PyObject *M_sys_exists( PyObject * self, PyObject * args );
@@ -79,6 +80,14 @@ static char M_sys_splitext_doc[] =
/this/that/file.ext -> ('/this/that/file','.ext').\n\
Return the pair (root, extension).";
+static char M_sys_fullpath_doc[] =
+ "(path) - Converts blender formatted 'path'\n\
+into a path that can be passed to open(...) and os.*\n\
+functions, returns a string \n\
+'//' - is converted to blenders basepath directory\n\
+ (useually the current blendfiles path)\n\
+'#' - is converted to the current frame number";
+
static char M_sys_makename_doc[] =
"(path = Blender.Get('filename'), ext = \"\", strip = 0) -\n\
Strip dir and extension from path, leaving only a name, then append 'ext'\n\
@@ -116,6 +125,7 @@ struct PyMethodDef M_sys_methods[] = {
{"dirname", M_sys_dirname, METH_VARARGS, M_sys_dirname_doc},
{"join", M_sys_join, METH_VARARGS, M_sys_join_doc},
{"splitext", M_sys_splitext, METH_VARARGS, M_sys_splitext_doc},
+ {"fullpath", M_sys_fullpath, METH_VARARGS, M_sys_fullpath_doc},
{"makename", ( PyCFunction ) M_sys_makename,
METH_VARARGS | METH_KEYWORDS,
M_sys_makename_doc},
@@ -294,9 +304,25 @@ static PyObject *M_sys_splitext( PyObjec
BLI_strncpy( ext, dot, n + 1 );
BLI_strncpy( path, name, dot - name + 1 );
-
+
return Py_BuildValue( "ss", path, ext );
}
+
+
+static PyObject *M_sys_fullpath( PyObject * self, PyObject * args )
+{
+ char *path;
+
+ if( !PyArg_ParseTuple( args, "s", &path) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument." );
+
+ BLI_convertstringcode(path, G.sce, G.scene->r.cfra);
+
+ return PyString_FromString(path);
+}
+
+
static PyObject *M_sys_makename( PyObject * self, PyObject * args,
PyObject * kw )
Index: source/blender/python/api2_2x/doc/Sys.py
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/doc/Sys.py,v
retrieving revision 1.8
diff -u -p -r1.8 Sys.py
--- source/blender/python/api2_2x/doc/Sys.py 25 Jul 2004 16:55:45 -0000 1.8
+++ source/blender/python/api2_2x/doc/Sys.py 6 Apr 2005 04:30:37 -0000
@@ -81,6 +81,20 @@ def splitext (path):
@rtype: list with two strings
@return: (root, ext)
"""
+
+def fullpath (path):
+ """
+ Converts a blender 'path' into an absolute path, replacing '//' the the current
+ blend files base path and '#' with the current frame number.
+ This new path can then be passed to generic python functions that don't
+ understand blenders relative paths.
+ This is also usefull for obtaining the name of the image that will
+ be saved when rendered.
+ @type path: string
+ @param path: a path name
+ @rtype: string
+ @return: path
+ """
def makename (path = "Blender.Get('filename')", ext = "", strip = 0):
"""
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
7e/d7/a34eae0da5cc85c7322b3938563d
Event Timeline
Log In to Comment