[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27140] trunk/blender/source/creator/ creator.c: support for relative file loading and python paths.

Campbell Barton ideasman42 at gmail.com
Thu Feb 25 17:08:32 CET 2010


Revision: 27140
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27140
Author:   campbellbarton
Date:     2010-02-25 17:08:32 +0100 (Thu, 25 Feb 2010)

Log Message:
-----------
support for relative file loading and python paths.
means you can do...
 blender -P foo.py
where foo is $PWD/foo.py

Modified Paths:
--------------
    trunk/blender/source/creator/creator.c

Modified: trunk/blender/source/creator/creator.c
===================================================================
--- trunk/blender/source/creator/creator.c	2010-02-25 15:41:46 UTC (rev 27139)
+++ trunk/blender/source/creator/creator.c	2010-02-25 16:08:32 UTC (rev 27140)
@@ -767,8 +767,14 @@
 
 static int run_python(int argc, char **argv, void *data)
 {
+#ifndef DISABLE_PYTHON
 	bContext *C = data;
-#ifndef DISABLE_PYTHON
+
+	/* Make the path absolute because its needed for relative linked blends to be found */
+	char filename[FILE_MAXDIR + FILE_MAXFILE];
+	BLI_strncpy(filename, argv[1], sizeof(filename));
+	BLI_convertstringcwd(filename);
+
 	/* workaround for scripts not getting a bpy.context.scene, causes internal errors elsewhere */
 	if (argc > 1) {
 		/* XXX, temp setting the WM is ugly, splash also does this :S */
@@ -778,13 +784,13 @@
 		if(wm->windows.first) {
 			CTX_wm_window_set(C, wm->windows.first);
 
-			BPY_run_python_script(C, argv[1], NULL, NULL); // use reports?
+			BPY_run_python_script(C, filename, NULL, NULL); // use reports?
 
 			CTX_wm_window_set(C, prevwin);
 		}
 		else {
 			fprintf(stderr, "Python script \"%s\" running with missing context data.\n", argv[1]);
-			BPY_run_python_script(C, argv[1], NULL, NULL); // use reports?
+			BPY_run_python_script(C, filename, NULL, NULL); // use reports?
 		}
 		return 1;
 	} else {
@@ -803,12 +809,11 @@
 
 	/* Make the path absolute because its needed for relative linked blends to be found */
 	char filename[FILE_MAXDIR + FILE_MAXFILE];
-
 	BLI_strncpy(filename, argv[0], sizeof(filename));
 	BLI_convertstringcwd(filename);
 
 	if (G.background) {
-		int retval = BKE_read_file(C, argv[0], NULL, NULL);
+		int retval = BKE_read_file(C, filename, NULL, NULL);
 
 		/*we successfully loaded a blend file, get sure that
 		pointcache works */





More information about the Bf-blender-cvs mailing list