Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-04-12 17:56:28 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-04-12 17:56:28 +0400
commiteb0b594d811a5840d67bcf8eb4845186695b6af9 (patch)
tree1a4aaf407c64bab2e361308043587debbeed5386 /io_mesh_stl/stl_utils.py
parent2dcebd82bf62c71aca900d75a68ef16c4935b280 (diff)
include blender version in STL ascii and binary, eg: Exported from Blender-2.62 (sub 3)
Diffstat (limited to 'io_mesh_stl/stl_utils.py')
-rw-r--r--io_mesh_stl/stl_utils.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/io_mesh_stl/stl_utils.py b/io_mesh_stl/stl_utils.py
index 7aae0645..be4dc0a6 100644
--- a/io_mesh_stl/stl_utils.py
+++ b/io_mesh_stl/stl_utils.py
@@ -23,7 +23,7 @@ Import and export STL files
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_HEADER = 80
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 @@ def _binary_write(filename, faces):
# 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 @@ def _ascii_write(filename, faces):
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):