Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
blender-addons
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blender
blender-addons
Commits
eb0b594d
Commit
eb0b594d
authored
13 years ago
by
Campbell Barton
Browse files
Options
Downloads
Patches
Plain Diff
include blender version in STL ascii and binary, eg: Exported from Blender-2.62 (sub 3)
parent
2dcebd82
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
io_mesh_stl/stl_utils.py
+10
-4
10 additions, 4 deletions
io_mesh_stl/stl_utils.py
with
10 additions
and
4 deletions
io_mesh_stl/stl_utils.py
+
10
−
4
View file @
eb0b594d
...
@@ -23,7 +23,7 @@ Import and export STL files
...
@@ -23,7 +23,7 @@ Import and export STL files
Used as a blender script, it load all the stl files in the scene:
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
import
struct
...
@@ -86,6 +86,11 @@ BINARY_HEADER = 80
...
@@ -86,6 +86,11 @@ BINARY_HEADER = 80
BINARY_STRIDE
=
12
*
4
+
2
BINARY_STRIDE
=
12
*
4
+
2
def
_header_version
():
import
bpy
return
"
Exported from Blender-
"
+
bpy
.
app
.
version_string
def
_is_ascii_file
(
data
):
def
_is_ascii_file
(
data
):
'''
'''
This function returns True if the data represents an ASCII file.
This function returns True if the data represents an ASCII file.
...
@@ -176,12 +181,13 @@ def _binary_write(filename, faces):
...
@@ -176,12 +181,13 @@ def _binary_write(filename, faces):
# header, with correct value now
# header, with correct value now
data
.
seek
(
0
)
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
):
def
_ascii_write
(
filename
,
faces
):
with
open
(
filename
,
'
w
'
)
as
data
:
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
:
for
face
in
faces
:
data
.
write
(
'''
facet normal 0 0 0
\n
outer loop
\n
'''
)
data
.
write
(
'''
facet normal 0 0 0
\n
outer loop
\n
'''
)
...
@@ -189,7 +195,7 @@ def _ascii_write(filename, faces):
...
@@ -189,7 +195,7 @@ def _ascii_write(filename, faces):
data
.
write
(
'
vertex %f %f %f
\n
'
%
vert
[:])
data
.
write
(
'
vertex %f %f %f
\n
'
%
vert
[:])
data
.
write
(
'
endloop
\n
endfacet
\n
'
)
data
.
write
(
'
endloop
\n
endfacet
\n
'
)
data
.
write
(
'
endsolid
Exported from blender
\n
'
)
data
.
write
(
'
endsolid
%s
\n
'
%
header
)
def
write_stl
(
filename
,
faces
,
ascii
=
False
):
def
write_stl
(
filename
,
faces
,
ascii
=
False
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment