[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3251] trunk/py/scripts/addons/ io_mesh_stl/stl_utils.py: include blender version in STL ascii and binary, eg: Exported from Blender-2.62 (sub 3)
Campbell Barton
ideasman42 at gmail.com
Thu Apr 12 15:56:28 CEST 2012
Revision: 3251
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3251
Author: campbellbarton
Date: 2012-04-12 13:56:28 +0000 (Thu, 12 Apr 2012)
Log Message:
-----------
include blender version in STL ascii and binary, eg: Exported from Blender-2.62 (sub 3)
Modified Paths:
--------------
trunk/py/scripts/addons/io_mesh_stl/stl_utils.py
Modified: trunk/py/scripts/addons/io_mesh_stl/stl_utils.py
===================================================================
--- trunk/py/scripts/addons/io_mesh_stl/stl_utils.py 2012-04-12 13:12:13 UTC (rev 3250)
+++ trunk/py/scripts/addons/io_mesh_stl/stl_utils.py 2012-04-12 13:56:28 UTC (rev 3251)
@@ -23,7 +23,7 @@
Used as a blender script, it load all the stl files in the scene:
-blender -P stl_utils.py -- file1.stl file2.stl file3.stl ...
+blender --python stl_utils.py -- file1.stl file2.stl file3.stl ...
'''
import struct
@@ -86,6 +86,11 @@
BINARY_STRIDE = 12 * 4 + 2
+def _header_version():
+ import bpy
+ return "Exported from Blender-" + bpy.app.version_string
+
+
def _is_ascii_file(data):
'''
This function returns True if the data represents an ASCII file.
@@ -176,12 +181,13 @@
# header, with correct value now
data.seek(0)
- data.write(struct.pack('<80sI', b"Exported from blender", nb))
+ data.write(struct.pack('<80sI', _header_version().encode('ascii'), nb))
def _ascii_write(filename, faces):
with open(filename, 'w') as data:
- data.write('solid Exported from blender\n')
+ header = _header_version()
+ data.write('solid %s\n' % header)
for face in faces:
data.write('''facet normal 0 0 0\nouter loop\n''')
@@ -189,7 +195,7 @@
data.write('vertex %f %f %f\n' % vert[:])
data.write('endloop\nendfacet\n')
- data.write('endsolid Exported from blender\n')
+ data.write('endsolid %s\n' % header)
def write_stl(filename, faces, ascii=False):
More information about the Bf-extensions-cvs
mailing list