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
50a1719f
Commit
50a1719f
authored
Oct 22, 2014
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finally fix #561: get rid of most print calls in printrun
parent
1ae900f8
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
26 additions
and
23 deletions
+26
-23
gcodeplater.py
printrun/gcodeplater.py
+3
-2
gcview.py
printrun/gcview.py
+3
-2
__init__.py
printrun/gui/__init__.py
+3
-1
injectgcode.py
printrun/injectgcode.py
+4
-2
objectplater.py
printrun/objectplater.py
+3
-2
printcore.py
printrun/printcore.py
+1
-1
stlplater.py
printrun/stlplater.py
+7
-8
stltool.py
printrun/stltool.py
+2
-3
stlview.py
printrun/stlview.py
+0
-2
No files found.
printrun/gcodeplater.py
View file @
50a1719f
...
@@ -27,6 +27,7 @@ import time
...
@@ -27,6 +27,7 @@ import time
import
types
import
types
import
re
import
re
import
math
import
math
import
logging
from
printrun
import
gcoder
from
printrun
import
gcoder
from
printrun.objectplater
import
Plater
from
printrun.objectplater
import
Plater
...
@@ -189,7 +190,7 @@ class GcodePlater(Plater):
...
@@ -189,7 +190,7 @@ class GcodePlater(Plater):
laste
[
model_i
]
=
analyzer
.
current_e
laste
[
model_i
]
=
analyzer
.
current_e
lastrelative
[
model_i
]
=
analyzer
.
relative
lastrelative
[
model_i
]
=
analyzer
.
relative
lasttool
[
model_i
]
=
analyzer
.
current_tool
lasttool
[
model_i
]
=
analyzer
.
current_tool
print
_
(
"Exported merged G-Codes to
%
s"
)
%
name
logging
.
info
(
_
(
"Exported merged G-Codes to
%
s"
)
%
name
)
def
export_sequential
(
self
,
name
):
def
export_sequential
(
self
,
name
):
models
=
self
.
models
.
values
()
models
=
self
.
models
.
values
()
...
@@ -226,7 +227,7 @@ class GcodePlater(Plater):
...
@@ -226,7 +227,7 @@ class GcodePlater(Plater):
-
trans
[
1
]
+
gline
.
current_y
,
-
trans
[
1
]
+
gline
.
current_y
,
-
trans
[
2
]
+
gline
.
current_z
)
-
trans
[
2
]
+
gline
.
current_z
)
break
break
print
_
(
"Exported merged G-Codes to
%
s"
)
%
name
logging
.
info
(
_
(
"Exported merged G-Codes to
%
s"
)
%
name
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
app
=
wx
.
App
(
False
)
app
=
wx
.
App
(
False
)
...
...
printrun/gcview.py
View file @
50a1719f
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU General Public License
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
import
logging
import
wx
import
wx
from
.
import
gcoder
from
.
import
gcoder
...
@@ -94,7 +95,7 @@ class GcodeViewPanel(wxGLPanel):
...
@@ -94,7 +95,7 @@ class GcodeViewPanel(wxGLPanel):
if
filtered
:
if
filtered
:
injector
(
self
.
parent
.
model
.
gcode
,
l
,
filtered
[
0
])
injector
(
self
.
parent
.
model
.
gcode
,
l
,
filtered
[
0
])
else
:
else
:
print
_
(
"Invalid layer for injection"
)
logging
.
error
(
_
(
"Invalid layer for injection"
)
)
def
editlayer
(
self
):
def
editlayer
(
self
):
l
=
self
.
parent
.
model
.
num_layers_to_draw
l
=
self
.
parent
.
model
.
num_layers_to_draw
...
@@ -102,7 +103,7 @@ class GcodeViewPanel(wxGLPanel):
...
@@ -102,7 +103,7 @@ class GcodeViewPanel(wxGLPanel):
if
filtered
:
if
filtered
:
injector_edit
(
self
.
parent
.
model
.
gcode
,
l
,
filtered
[
0
])
injector_edit
(
self
.
parent
.
model
.
gcode
,
l
,
filtered
[
0
])
else
:
else
:
print
_
(
"Invalid layer for edition"
)
logging
.
error
(
_
(
"Invalid layer for edition"
)
)
def
setlayercb
(
self
,
layer
):
def
setlayercb
(
self
,
layer
):
pass
pass
...
...
printrun/gui/__init__.py
View file @
50a1719f
...
@@ -13,10 +13,12 @@
...
@@ -13,10 +13,12 @@
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU General Public License
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
import
logging
try
:
try
:
import
wx
import
wx
except
:
except
:
print
_
(
"WX is not installed. This program requires WX to run."
)
logging
.
error
(
_
(
"WX is not installed. This program requires WX to run."
)
)
raise
raise
from
printrun.utils
import
install_locale
from
printrun.utils
import
install_locale
...
...
printrun/injectgcode.py
View file @
50a1719f
...
@@ -13,6 +13,8 @@
...
@@ -13,6 +13,8 @@
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU General Public License
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
import
logging
from
.gui.widgets
import
MacroEditor
from
.gui.widgets
import
MacroEditor
from
.utils
import
install_locale
from
.utils
import
install_locale
...
@@ -35,9 +37,9 @@ def injector_edit(gcode, viz_layer, layer_idx):
...
@@ -35,9 +37,9 @@ def injector_edit(gcode, viz_layer, layer_idx):
def
inject
(
gcode
,
viz_layer
,
layer_idx
,
toadd
):
def
inject
(
gcode
,
viz_layer
,
layer_idx
,
toadd
):
# TODO: save modified gcode after injection ?
# TODO: save modified gcode after injection ?
nlines
=
len
(
gcode
.
prepend_to_layer
(
toadd
,
layer_idx
))
nlines
=
len
(
gcode
.
prepend_to_layer
(
toadd
,
layer_idx
))
print
_
(
"Successfully injected
%
d lines at beginning of layer
%
d"
)
%
(
nlines
,
viz_layer
)
logging
.
info
(
_
(
"Successfully injected
%
d lines at beginning of layer
%
d"
)
%
(
nlines
,
viz_layer
)
)
def
rewritelayer
(
gcode
,
viz_layer
,
layer_idx
,
toadd
):
def
rewritelayer
(
gcode
,
viz_layer
,
layer_idx
,
toadd
):
# TODO: save modified gcode after edit ?
# TODO: save modified gcode after edit ?
nlines
=
len
(
gcode
.
rewrite_layer
(
toadd
,
layer_idx
))
nlines
=
len
(
gcode
.
rewrite_layer
(
toadd
,
layer_idx
))
print
_
(
"Successfully edited layer
%
d (which now contains
%
d lines)"
)
%
(
viz_layer
,
nlines
)
logging
.
info
(
_
(
"Successfully edited layer
%
d (which now contains
%
d lines)"
)
%
(
viz_layer
,
nlines
)
)
printrun/objectplater.py
View file @
50a1719f
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
from
.utils
import
install_locale
,
iconfile
from
.utils
import
install_locale
,
iconfile
install_locale
(
'plater'
)
install_locale
(
'plater'
)
import
logging
import
os
import
os
import
types
import
types
import
wx
import
wx
...
@@ -148,7 +149,7 @@ class Plater(wx.Frame):
...
@@ -148,7 +149,7 @@ class Plater(wx.Frame):
model
.
rot
+=
angle
model
.
rot
+=
angle
def
autoplate
(
self
,
event
=
None
):
def
autoplate
(
self
,
event
=
None
):
print
_
(
"Autoplating"
)
logging
.
info
(
_
(
"Autoplating"
)
)
separation
=
2
separation
=
2
try
:
try
:
from
printrun
import
packer
from
printrun
import
packer
...
@@ -195,7 +196,7 @@ class Plater(wx.Frame):
...
@@ -195,7 +196,7 @@ class Plater(wx.Frame):
max
[
1
]
=
cursor
[
1
]
+
x
max
[
1
]
=
cursor
[
1
]
+
x
cursor
[
0
]
+=
x
+
separation
cursor
[
0
]
+=
x
+
separation
if
(
cursor
[
1
]
+
y
)
>=
bedsize
[
1
]:
if
(
cursor
[
1
]
+
y
)
>=
bedsize
[
1
]:
print
_
(
"Bed full, sorry sir :("
)
logging
.
info
(
_
(
"Bed full, sorry sir :("
)
)
self
.
Refresh
()
self
.
Refresh
()
return
return
centerx
=
self
.
build_dimensions
[
0
]
/
2
+
self
.
build_dimensions
[
3
]
centerx
=
self
.
build_dimensions
[
0
]
/
2
+
self
.
build_dimensions
[
3
]
...
...
printrun/printcore.py
View file @
50a1719f
...
@@ -263,7 +263,7 @@ class printcore():
...
@@ -263,7 +263,7 @@ class printcore():
while
not
self
.
online
and
self
.
_listen_can_continue
():
while
not
self
.
online
and
self
.
_listen_can_continue
():
self
.
_send
(
"M105"
)
self
.
_send
(
"M105"
)
if
self
.
writefailures
>=
4
:
if
self
.
writefailures
>=
4
:
print
_
(
"Aborting connection attempt after 4 failed writes."
)
logging
.
error
(
_
(
"Aborting connection attempt after 4 failed writes."
)
)
return
return
empty_lines
=
0
empty_lines
=
0
while
self
.
_listen_can_continue
():
while
self
.
_listen_can_continue
():
...
...
printrun/stlplater.py
View file @
50a1719f
...
@@ -137,7 +137,6 @@ class showstl(wx.Window):
...
@@ -137,7 +137,6 @@ class showstl(wx.Window):
def
keypress
(
self
,
event
):
def
keypress
(
self
,
event
):
"""gets keypress events and moves/rotates acive shape"""
"""gets keypress events and moves/rotates acive shape"""
keycode
=
event
.
GetKeyCode
()
keycode
=
event
.
GetKeyCode
()
# print keycode
step
=
5
step
=
5
angle
=
18
angle
=
18
if
event
.
ControlDown
():
if
event
.
ControlDown
():
...
@@ -294,7 +293,7 @@ class StlPlater(Plater):
...
@@ -294,7 +293,7 @@ class StlPlater(Plater):
model
=
self
.
models
[
name
]
model
=
self
.
models
[
name
]
transformation
=
transformation_matrix
(
model
)
transformation
=
transformation_matrix
(
model
)
transformed
=
model
.
transform
(
transformation
)
transformed
=
model
.
transform
(
transformation
)
print
_
(
"Cutting
%
s alongside
%
s axis"
)
%
(
name
,
self
.
cutting_axis
)
logging
.
info
(
_
(
"Cutting
%
s alongside
%
s axis"
)
%
(
name
,
self
.
cutting_axis
)
)
axes
=
[
"x"
,
"y"
,
"z"
]
axes
=
[
"x"
,
"y"
,
"z"
]
cut
=
transformed
.
cut
(
axes
.
index
(
self
.
cutting_axis
),
cut
=
transformed
.
cut
(
axes
.
index
(
self
.
cutting_axis
),
self
.
cutting_direction
,
self
.
cutting_direction
,
...
@@ -340,7 +339,7 @@ class StlPlater(Plater):
...
@@ -340,7 +339,7 @@ class StlPlater(Plater):
transformation
=
transformation_matrix
(
model
)
transformation
=
transformation_matrix
(
model
)
transformed
=
model
.
transform
(
transformation
)
transformed
=
model
.
transform
(
transformation
)
if
not
transformed
.
intersect_box
(
ray_near
,
ray_far
):
if
not
transformed
.
intersect_box
(
ray_near
,
ray_far
):
print
"Skipping
%
s for rebase search"
%
key
logging
.
debug
(
"Skipping
%
s for rebase search"
%
key
)
continue
continue
facet
,
facet_dist
=
transformed
.
intersect
(
ray_near
,
ray_far
)
facet
,
facet_dist
=
transformed
.
intersect
(
ray_near
,
ray_far
)
if
facet
is
not
None
and
facet_dist
<
best_dist
:
if
facet
is
not
None
and
facet_dist
<
best_dist
:
...
@@ -348,7 +347,7 @@ class StlPlater(Plater):
...
@@ -348,7 +347,7 @@ class StlPlater(Plater):
best_facet
=
facet
best_facet
=
facet
best_dist
=
facet_dist
best_dist
=
facet_dist
if
best_match
is
not
None
:
if
best_match
is
not
None
:
print
"Rebasing
%
s"
%
best_match
logging
.
info
(
"Rebasing
%
s"
%
best_match
)
model
=
self
.
models
[
best_match
]
model
=
self
.
models
[
best_match
]
newmodel
=
model
.
rebase
(
best_facet
)
newmodel
=
model
.
rebase
(
best_facet
)
newmodel
.
offsets
=
list
(
model
.
offsets
)
newmodel
.
offsets
=
list
(
model
.
offsets
)
...
@@ -422,7 +421,7 @@ class StlPlater(Plater):
...
@@ -422,7 +421,7 @@ class StlPlater(Plater):
def
load_stl
(
self
,
name
):
def
load_stl
(
self
,
name
):
if
not
os
.
path
.
exists
(
name
):
if
not
os
.
path
.
exists
(
name
):
print
_
(
"Couldn't load non-existing file
%
s"
)
%
name
logging
.
error
(
_
(
"Couldn't load non-existing file
%
s"
)
%
name
)
return
return
path
=
os
.
path
.
split
(
name
)[
0
]
path
=
os
.
path
.
split
(
name
)[
0
]
self
.
basedir
=
path
self
.
basedir
=
path
...
@@ -472,7 +471,7 @@ class StlPlater(Plater):
...
@@ -472,7 +471,7 @@ class StlPlater(Plater):
model
=
model
.
transform
(
transformation_matrix
(
model
))
model
=
model
.
transform
(
transformation_matrix
(
model
))
facets
+=
model
.
facets
facets
+=
model
.
facets
stltool
.
emitstl
(
name
,
facets
,
"plater_export"
)
stltool
.
emitstl
(
name
,
facets
,
"plater_export"
)
print
_
(
"Wrote plate to
%
s"
)
%
name
logging
.
info
(
_
(
"Wrote plate to
%
s"
)
%
name
)
def
autoplate
(
self
,
event
=
None
):
def
autoplate
(
self
,
event
=
None
):
try
:
try
:
...
@@ -484,7 +483,7 @@ class StlPlater(Plater):
...
@@ -484,7 +483,7 @@ class StlPlater(Plater):
super
(
StlPlater
,
self
)
.
autoplate
()
super
(
StlPlater
,
self
)
.
autoplate
()
def
autoplate_simarrange
(
self
):
def
autoplate_simarrange
(
self
):
print
_
(
"Autoplating using simarrange"
)
logging
.
info
(
_
(
"Autoplating using simarrange"
)
)
models
=
dict
(
self
.
models
)
models
=
dict
(
self
.
models
)
files
=
[
model
.
filename
for
model
in
models
.
values
()]
files
=
[
model
.
filename
for
model
in
models
.
values
()]
command
=
[
self
.
simarrange_path
,
"--dryrun"
,
command
=
[
self
.
simarrange_path
,
"--dryrun"
,
...
@@ -499,7 +498,7 @@ class StlPlater(Plater):
...
@@ -499,7 +498,7 @@ class StlPlater(Plater):
if
"Generating plate"
in
line
:
if
"Generating plate"
in
line
:
plateid
=
int
(
line
.
split
()[
-
1
])
plateid
=
int
(
line
.
split
()[
-
1
])
if
plateid
>
0
:
if
plateid
>
0
:
print
_
(
"Plate full, please remove some objects"
)
logging
.
error
(
_
(
"Plate full, please remove some objects"
)
)
break
break
if
"File:"
in
line
:
if
"File:"
in
line
:
bits
=
pos_regexp
.
match
(
line
)
.
groups
()
bits
=
pos_regexp
.
match
(
line
)
.
groups
()
...
...
printrun/stltool.py
View file @
50a1719f
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
import
sys
import
sys
import
struct
import
struct
import
math
import
math
import
logging
import
numpy
import
numpy
import
numpy.linalg
import
numpy.linalg
...
@@ -170,7 +171,7 @@ class stl(object):
...
@@ -170,7 +171,7 @@ class stl(object):
if
not
self
.
parseline
(
line
):
if
not
self
.
parseline
(
line
):
return
return
else
:
else
:
print
"Not an ascii stl solid - attempting to parse as binary"
logging
.
warning
(
"Not an ascii stl solid - attempting to parse as binary"
)
f
=
open
(
filename
,
"rb"
)
f
=
open
(
filename
,
"rb"
)
buf
=
f
.
read
(
84
)
buf
=
f
.
read
(
84
)
while
len
(
buf
)
<
84
:
while
len
(
buf
)
<
84
:
...
@@ -348,8 +349,6 @@ class stl(object):
...
@@ -348,8 +349,6 @@ class stl(object):
if
l
.
startswith
(
"solid"
):
if
l
.
startswith
(
"solid"
):
self
.
insolid
=
1
self
.
insolid
=
1
self
.
name
=
l
[
6
:]
self
.
name
=
l
[
6
:]
# print self.name
elif
l
.
startswith
(
"endsolid"
):
elif
l
.
startswith
(
"endsolid"
):
self
.
insolid
=
0
self
.
insolid
=
0
return
0
return
0
...
...
printrun/stlview.py
View file @
50a1719f
...
@@ -55,7 +55,6 @@ class stlview(object):
...
@@ -55,7 +55,6 @@ class stlview(object):
# Create a list of triangle indices.
# Create a list of triangle indices.
indices
=
range
(
3
*
len
(
facets
))
# [[3*i, 3*i+1, 3*i+2] for i in xrange(len(facets))]
indices
=
range
(
3
*
len
(
facets
))
# [[3*i, 3*i+1, 3*i+2] for i in xrange(len(facets))]
# print indices[:10]
self
.
vertex_list
=
batch
.
add_indexed
(
len
(
vertices
)
//
3
,
self
.
vertex_list
=
batch
.
add_indexed
(
len
(
vertices
)
//
3
,
GL_TRIANGLES
,
GL_TRIANGLES
,
None
,
# group,
None
,
# group,
...
@@ -206,7 +205,6 @@ class StlViewPanel(wxGLPanel):
...
@@ -206,7 +205,6 @@ class StlViewPanel(wxGLPanel):
def
keypress
(
self
,
event
):
def
keypress
(
self
,
event
):
"""gets keypress events and moves/rotates acive shape"""
"""gets keypress events and moves/rotates acive shape"""
keycode
=
event
.
GetKeyCode
()
keycode
=
event
.
GetKeyCode
()
print
keycode
step
=
5
step
=
5
angle
=
18
angle
=
18
if
event
.
ControlDown
():
if
event
.
ControlDown
():
...
...
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