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
3b18f026
Commit
3b18f026
authored
11 years ago
by
Campbell Barton
Browse files
Options
Downloads
Patches
Plain Diff
STL now always exports normals.
Normals are not optional for STL so remove the option from the UI.
parent
5da29460
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
io_mesh_stl/__init__.py
+0
-6
0 additions, 6 deletions
io_mesh_stl/__init__.py
io_mesh_stl/stl_utils.py
+16
-38
16 additions, 38 deletions
io_mesh_stl/stl_utils.py
with
16 additions
and
44 deletions
io_mesh_stl/__init__.py
+
0
−
6
View file @
3b18f026
...
@@ -44,7 +44,6 @@ Import-Export STL files (binary or ascii)
...
@@ -44,7 +44,6 @@ Import-Export STL files (binary or ascii)
Issues:
Issues:
Import:
Import:
- Does not handle the normal of the triangles
- Does not handle endien
- Does not handle endien
"""
"""
...
@@ -128,11 +127,6 @@ class ExportSTL(Operator, ExportHelper):
...
@@ -128,11 +127,6 @@ class ExportSTL(Operator, ExportHelper):
description
=
"
Save the file in ASCII file format
"
,
description
=
"
Save the file in ASCII file format
"
,
default
=
False
,
default
=
False
,
)
)
use_normals
=
BoolProperty
(
name
=
"
Write Normals
"
,
description
=
"
Export one normal per face, to represent flat faces and sharp edges
"
,
default
=
False
,
)
use_mesh_modifiers
=
BoolProperty
(
use_mesh_modifiers
=
BoolProperty
(
name
=
"
Apply Modifiers
"
,
name
=
"
Apply Modifiers
"
,
description
=
"
Apply the modifiers before saving
"
,
description
=
"
Apply the modifiers before saving
"
,
...
...
This diff is collapsed.
Click to expand it.
io_mesh_stl/stl_utils.py
+
16
−
38
View file @
3b18f026
...
@@ -157,7 +157,7 @@ def _ascii_read(data):
...
@@ -157,7 +157,7 @@ def _ascii_read(data):
for
l_item
in
(
l
,
data
.
readline
(),
data
.
readline
())]
for
l_item
in
(
l
,
data
.
readline
(),
data
.
readline
())]
def
_binary_write
(
filepath
,
faces
,
use_normals
):
def
_binary_write
(
filepath
,
faces
):
with
open
(
filepath
,
'
wb
'
)
as
data
:
with
open
(
filepath
,
'
wb
'
)
as
data
:
fw
=
data
.
write
fw
=
data
.
write
# header
# header
...
@@ -171,49 +171,31 @@ def _binary_write(filepath, faces, use_normals):
...
@@ -171,49 +171,31 @@ def _binary_write(filepath, faces, use_normals):
# number of vertices written
# number of vertices written
nb
=
0
nb
=
0
if
use_normals
:
for
face
in
faces
:
for
face
in
faces
:
# calculate face normal
# calculate face normal
# write normal + vertexes + pad as attributes
# write normal + vertexes + pad as attributes
fw
(
struct
.
pack
(
'
<3f
'
,
*
normal
(
*
face
))
+
pack
(
*
itertools
.
chain
.
from_iterable
(
face
)))
fw
(
struct
.
pack
(
'
<3f
'
,
*
normal
(
*
face
))
+
pack
(
*
itertools
.
chain
.
from_iterable
(
face
)))
# attribute byte count (unused)
# attribute byte count (unused)
fw
(
b
'
\0\0
'
)
fw
(
b
'
\0\0
'
)
nb
+=
1
nb
+=
1
else
:
# pad is to remove normal, we do use them
pad
=
b
'
\0
'
*
struct
.
calcsize
(
'
<3f
'
)
for
face
in
faces
:
# write pad as normal + vertexes + pad as attributes
fw
(
pad
+
pack
(
*
itertools
.
chain
.
from_iterable
(
face
)))
# attribute byte count (unused)
fw
(
b
'
\0\0
'
)
nb
+=
1
# header, with correct value now
# header, with correct value now
data
.
seek
(
0
)
data
.
seek
(
0
)
fw
(
struct
.
pack
(
'
<80sI
'
,
_header_version
().
encode
(
'
ascii
'
),
nb
))
fw
(
struct
.
pack
(
'
<80sI
'
,
_header_version
().
encode
(
'
ascii
'
),
nb
))
def
_ascii_write
(
filepath
,
faces
,
use_normals
):
def
_ascii_write
(
filepath
,
faces
):
with
open
(
filepath
,
'
w
'
)
as
data
:
with
open
(
filepath
,
'
w
'
)
as
data
:
fw
=
data
.
write
fw
=
data
.
write
header
=
_header_version
()
header
=
_header_version
()
fw
(
'
solid %s
\n
'
%
header
)
fw
(
'
solid %s
\n
'
%
header
)
if
use_normals
:
for
face
in
faces
:
for
face
in
faces
:
# calculate face normal
# calculate face normal
fw
(
'
facet normal %f %f %f
\n
outer loop
\n
'
%
normal
(
*
face
)[:])
fw
(
'
facet normal %f %f %f
\n
outer loop
\n
'
%
normal
(
*
face
)[:])
for
vert
in
face
:
for
vert
in
face
:
fw
(
'
vertex %f %f %f
\n
'
%
vert
[:])
fw
(
'
vertex %f %f %f
\n
'
%
vert
[:])
fw
(
'
endloop
\n
endfacet
\n
'
)
fw
(
'
endloop
\n
endfacet
\n
'
)
else
:
for
face
in
faces
:
fw
(
'
outer loop
\n
'
)
for
vert
in
face
:
fw
(
'
vertex %f %f %f
\n
'
%
vert
[:])
fw
(
'
endloop
\n
endfacet
\n
'
)
fw
(
'
endsolid %s
\n
'
%
header
)
fw
(
'
endsolid %s
\n
'
%
header
)
...
@@ -221,7 +203,6 @@ def _ascii_write(filepath, faces, use_normals):
...
@@ -221,7 +203,6 @@ def _ascii_write(filepath, faces, use_normals):
def
write_stl
(
filepath
=
""
,
def
write_stl
(
filepath
=
""
,
faces
=
(),
faces
=
(),
ascii
=
False
,
ascii
=
False
,
use_normals
=
False
,
):
):
"""
"""
Write a stl file from faces,
Write a stl file from faces,
...
@@ -234,11 +215,8 @@ def write_stl(filepath="",
...
@@ -234,11 +215,8 @@ def write_stl(filepath="",
ascii
ascii
save the file in ascii format (very huge)
save the file in ascii format (very huge)
use_normals
calculate face normals and write them
"""
"""
(
_ascii_write
if
ascii
else
_binary_write
)(
filepath
,
faces
,
use_normals
)
(
_ascii_write
if
ascii
else
_binary_write
)(
filepath
,
faces
)
def
read_stl
(
filepath
):
def
read_stl
(
filepath
):
...
...
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