[ #4227 ] Determine the "real" current filename via Python
authorCampbell Barton <ideasman42@gmail.com>
Mon, 19 Mar 2007 01:51:54 +0000 (01:51 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 19 Mar 2007 01:51:54 +0000 (01:51 +0000)
applied. tested and this is how "filename" should work, so changed Blender.Get("filename") to return None instead of the last opened file.

source/blender/python/api2_2x/Blender.c

index a18faf6ac997635c7e795189c0bacfee7998be6f..859cd32d6709940449b08186f3e67c75355952a3 100644 (file)
@@ -306,8 +306,12 @@ static PyObject *Blender_Get( PyObject * self, PyObject * args )
                ret = PyInt_FromLong( G.scene->r.sfra );
        else if( StringEqual( str, "endframe" ) )
                ret = PyInt_FromLong( G.scene->r.efra );
-       else if( StringEqual( str, "filename" ) )
-               ret = PyString_FromString( G.sce );
+       else if( StringEqual( str, "filename" ) ) {
+               if ( strstr(G.main->name, ".B.blend") != 0)
+                       ret = EXPP_incr_ret( Py_None );
+               else
+                       ret = PyString_FromString(G.main->name);
+       }
        else if( StringEqual( str, "homedir" ) ) {
                char *hdir = bpy_gethome(0);
                if( hdir && BLI_exists( hdir ))