[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25590] trunk/blender: new python module constants
Campbell Barton
ideasman42 at gmail.com
Mon Dec 28 11:00:04 CET 2009
Revision: 25590
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25590
Author: campbellbarton
Date: 2009-12-28 11:00:04 +0100 (Mon, 28 Dec 2009)
Log Message:
-----------
new python module constants
* bpy.home - result of BLI_gethome()
* bpy.version - BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION
* bpy.version_string, as above, formatted: "%d.%02d (sub %d)"
Modified Paths:
--------------
trunk/blender/release/scripts/io/export_fbx.py
trunk/blender/release/scripts/io/export_obj.py
trunk/blender/release/scripts/io/export_ply.py
trunk/blender/release/scripts/modules/bpy/__init__.py
trunk/blender/source/blender/python/intern/bpy_interface.c
Modified: trunk/blender/release/scripts/io/export_fbx.py
===================================================================
--- trunk/blender/release/scripts/io/export_fbx.py 2009-12-28 09:19:32 UTC (rev 25589)
+++ trunk/blender/release/scripts/io/export_fbx.py 2009-12-28 10:00:04 UTC (rev 25590)
@@ -651,9 +651,9 @@
}''' % (curtime))
file.write('\nCreationTime: "%.4i-%.2i-%.2i %.2i:%.2i:%.2i:000"' % curtime)
- file.write('\nCreator: "Blender3D version 2.5"')
-# file.write('\nCreator: "Blender3D version %.2f"' % Blender.Get('version'))
+ file.write('\nCreator: "Blender3D version %s"' % bpy.version_string)
+
pose_items = [] # list of (fbxName, matrix) to write pose data for, easier to collect allong the way
# --------------- funcs for exporting
Modified: trunk/blender/release/scripts/io/export_obj.py
===================================================================
--- trunk/blender/release/scripts/io/export_obj.py 2009-12-28 09:19:32 UTC (rev 25589)
+++ trunk/blender/release/scripts/io/export_obj.py 2009-12-28 10:00:04 UTC (rev 25590)
@@ -40,29 +40,6 @@
will be exported as mesh data.
"""
-
-# --------------------------------------------------------------------------
-# OBJ Export v1.1 by Campbell Barton (AKA Ideasman)
-# --------------------------------------------------------------------------
-# ***** BEGIN GPL LICENSE BLOCK *****
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-# ***** END GPL LICENCE BLOCK *****
-# --------------------------------------------------------------------------
-
# import math and other in functions that use them for the sake of fast Blender startup
# import math
import os
@@ -384,8 +361,7 @@
file = open(filename, "w")
# Write Header
- version = "2.5"
- file.write('# Blender3D v%s OBJ File: %s\n' % (version, bpy.data.filename.split('/')[-1].split('\\')[-1] ))
+ file.write('# Blender3D v%s OBJ File: %s\n' % (bpy.version_string, bpy.data.filename.split('/')[-1].split('\\')[-1] ))
file.write('# www.blender3d.org\n')
# Tell the obj file what material file to use.
Modified: trunk/blender/release/scripts/io/export_ply.py
===================================================================
--- trunk/blender/release/scripts/io/export_ply.py 2009-12-28 09:19:32 UTC (rev 25589)
+++ trunk/blender/release/scripts/io/export_ply.py 2009-12-28 10:00:04 UTC (rev 25590)
@@ -205,8 +205,7 @@
file.write('ply\n')
file.write('format ascii 1.0\n')
- version = "2.5" # Blender.Get('version')
- file.write('comment Created by Blender3D %s - www.blender.org, source file: %s\n' % (version, bpy.data.filename.split('/')[-1].split('\\')[-1]))
+ file.write('comment Created by Blender3D %s - www.blender.org, source file: %s\n' % (bpy.version_string, bpy.data.filename.split('/')[-1].split('\\')[-1]))
file.write('element vertex %d\n' % len(ply_verts))
@@ -327,3 +326,4 @@
if __name__ == "__main__":
bpy.ops.export.ply(path="/tmp/test.ply")
+
Modified: trunk/blender/release/scripts/modules/bpy/__init__.py
===================================================================
--- trunk/blender/release/scripts/modules/bpy/__init__.py 2009-12-28 09:19:32 UTC (rev 25589)
+++ trunk/blender/release/scripts/modules/bpy/__init__.py 2009-12-28 10:00:04 UTC (rev 25590)
@@ -99,4 +99,10 @@
else:
load_scripts()
+
+# constants
+version = _bpy._VERSION
+version_string = _bpy._VERSION_STR
+home = _bpy._HOME
+
_main()
Modified: trunk/blender/source/blender/python/intern/bpy_interface.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_interface.c 2009-12-28 09:19:32 UTC (rev 25589)
+++ trunk/blender/source/blender/python/intern/bpy_interface.c 2009-12-28 10:00:04 UTC (rev 25590)
@@ -59,6 +59,7 @@
#include "BLI_fileops.h"
#include "BLI_string.h"
+#include "BKE_blender.h"
#include "BKE_context.h"
#include "BKE_text.h"
#include "BKE_context.h"
@@ -220,6 +221,16 @@
PyModule_AddObject(mod, "context", (PyObject *)bpy_context_module);
}
+ /* blender info that wont change at runtime, add into _bpy */
+ {
+ PyObject *mod_dict= PyModule_GetDict(mod);
+ char tmpstr[256];
+ PyModule_AddStringConstant(mod, "_HOME", BLI_gethome());
+ PyDict_SetItemString(mod_dict, "_VERSION", Py_BuildValue("(iii)", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION));
+ sprintf(tmpstr, "%d.%02d (sub %d)", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION);
+ PyModule_AddStringConstant(mod, "_VERSION_STR", tmpstr);
+ }
+
/* add our own modules dir, this is a python package */
bpy_import_test("bpy");
}
More information about the Bf-blender-cvs
mailing list