Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Printrun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
Printrun
Commits
8d776b50
Commit
8d776b50
authored
Apr 05, 2014
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pythonize some file handling
parent
e94d076b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
26 deletions
+22
-26
stltool.py
printrun/stltool.py
+22
-26
No files found.
printrun/stltool.py
View file @
8d776b50
...
@@ -55,32 +55,28 @@ def emitstl(filename, facets = [], objname = "stltool_export", binary = 1):
...
@@ -55,32 +55,28 @@ def emitstl(filename, facets = [], objname = "stltool_export", binary = 1):
if
filename
is
None
:
if
filename
is
None
:
return
return
if
binary
:
if
binary
:
f
=
open
(
filename
,
"wb"
)
with
open
(
filename
,
"wb"
)
as
f
:
buf
=
""
.
join
([
"
\0
"
]
*
80
)
buf
=
""
.
join
([
"
\0
"
]
*
80
)
buf
+=
struct
.
pack
(
"<I"
,
len
(
facets
))
buf
+=
struct
.
pack
(
"<I"
,
len
(
facets
))
facetformat
=
struct
.
Struct
(
"<ffffffffffffH"
)
facetformat
=
struct
.
Struct
(
"<ffffffffffffH"
)
for
i
in
facets
:
for
i
in
facets
:
l
=
list
(
i
[
0
][:])
l
=
list
(
i
[
0
][:])
for
j
in
i
[
1
]:
for
j
in
i
[
1
]:
l
+=
j
[:]
l
+=
j
[:]
l
+=
[
0
]
l
+=
[
0
]
# print len(l)
# print len(l)
buf
+=
facetformat
.
pack
(
*
l
)
buf
+=
facetformat
.
pack
(
*
l
)
f
.
write
(
buf
)
f
.
write
(
buf
)
f
.
close
()
else
:
return
with
open
(
filename
,
"w"
)
as
f
:
f
.
write
(
"solid "
+
objname
+
"
\n
"
)
f
=
open
(
filename
,
"w"
)
for
i
in
facets
:
f
.
write
(
"solid "
+
objname
+
"
\n
"
)
f
.
write
(
" facet normal "
+
" "
.
join
(
map
(
str
,
i
[
0
]))
+
"
\n
outer loop
\n
"
)
for
i
in
facets
:
for
j
in
i
[
1
]:
f
.
write
(
" facet normal "
+
" "
.
join
(
map
(
str
,
i
[
0
]))
+
"
\n
outer loop
\n
"
)
f
.
write
(
" vertex "
+
" "
.
join
(
map
(
str
,
j
))
+
"
\n
"
)
for
j
in
i
[
1
]:
f
.
write
(
" endloop"
+
"
\n
"
)
f
.
write
(
" vertex "
+
" "
.
join
(
map
(
str
,
j
))
+
"
\n
"
)
f
.
write
(
" endfacet"
+
"
\n
"
)
f
.
write
(
" endloop"
+
"
\n
"
)
f
.
write
(
"endsolid "
+
objname
+
"
\n
"
)
f
.
write
(
" endfacet"
+
"
\n
"
)
f
.
write
(
"endsolid "
+
objname
+
"
\n
"
)
f
.
close
()
class
stl
(
object
):
class
stl
(
object
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment