diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-12-28 13:00:04 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-12-28 13:00:04 +0300 |
commit | 98f1d6957eccd3e7fab4274f29ee6a44de154210 (patch) | |
tree | c54dd13e29a47ea32d5d9dd9a1ef84583d9e1f9b | |
parent | 5f329190c9c2921966217611a3ce61f735ba64ec (diff) |
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)"
-rw-r--r-- | release/scripts/io/export_fbx.py | 4 | ||||
-rw-r--r-- | release/scripts/io/export_obj.py | 26 | ||||
-rw-r--r-- | release/scripts/io/export_ply.py | 4 | ||||
-rw-r--r-- | release/scripts/modules/bpy/__init__.py | 6 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_interface.c | 11 |
5 files changed, 22 insertions, 29 deletions
diff --git a/release/scripts/io/export_fbx.py b/release/scripts/io/export_fbx.py index 1899e4f4a84..6407f9b6e49 100644 --- a/release/scripts/io/export_fbx.py +++ b/release/scripts/io/export_fbx.py @@ -651,8 +651,8 @@ def write(filename, batch_objects = None, \ }''' % (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 diff --git a/release/scripts/io/export_obj.py b/release/scripts/io/export_obj.py index 5b55c5159a6..6135375d185 100644 --- a/release/scripts/io/export_obj.py +++ b/release/scripts/io/export_obj.py @@ -40,29 +40,6 @@ All objects that can be represented as a mesh (mesh, curve, metaball, surface, t 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 @@ def write(filename, objects, scene, 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. diff --git a/release/scripts/io/export_ply.py b/release/scripts/io/export_ply.py index f3f4948fc57..3c9e1f86ee2 100644 --- a/release/scripts/io/export_ply.py +++ b/release/scripts/io/export_ply.py @@ -205,8 +205,7 @@ def write(filename, scene, ob, \ 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 @@ bpy.types.INFO_MT_file_export.append(menu_func) if __name__ == "__main__": bpy.ops.export.ply(path="/tmp/test.ply") + diff --git a/release/scripts/modules/bpy/__init__.py b/release/scripts/modules/bpy/__init__.py index 5fd0d17630d..65bf75b43e9 100644 --- a/release/scripts/modules/bpy/__init__.py +++ b/release/scripts/modules/bpy/__init__.py @@ -99,4 +99,10 @@ def _main(): else: load_scripts() + +# constants +version = _bpy._VERSION +version_string = _bpy._VERSION_STR +home = _bpy._HOME + _main() diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 44e3c5a2dd5..5ac3a233e11 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -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 @@ static void bpy_init_modules( void ) 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"); } |