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
de535f11
Commit
de535f11
authored
Apr 30, 2016
by
Kliment Yanev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
When multiple extruders are used, report material use for each extruder
parent
bd896e91
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
1 deletion
+53
-1
gcoder.py
printrun/gcoder.py
+50
-1
pronterface.py
printrun/pronterface.py
+3
-0
No files found.
printrun/gcoder.py
View file @
de535f11
...
@@ -134,8 +134,11 @@ class GCode(object):
...
@@ -134,8 +134,11 @@ class GCode(object):
current_z
=
0
current_z
=
0
# For E this is the absolute position from machine start
# For E this is the absolute position from machine start
current_e
=
0
current_e
=
0
current_e_multi
=
[
0
]
total_e
=
0
total_e
=
0
total_e_multi
=
[
0
]
max_e
=
0
max_e
=
0
max_e_multi
=
[
0
]
# Current feedrate
# Current feedrate
current_f
=
0
current_f
=
0
# Offset: current offset between the machine origin and the machine current
# Offset: current offset between the machine origin and the machine current
...
@@ -144,6 +147,8 @@ class GCode(object):
...
@@ -144,6 +147,8 @@ class GCode(object):
offset_y
=
0
offset_y
=
0
offset_z
=
0
offset_z
=
0
offset_e
=
0
offset_e
=
0
offset_e_multi
=
[
0
]
# Expected behavior:
# Expected behavior:
# - G28 X => X axis is homed, offset_x <- 0, current_x <- home_x
# - G28 X => X axis is homed, offset_x <- 0, current_x <- home_x
# - G92 Xk => X axis does not move, so current_x does not change
# - G92 Xk => X axis does not move, so current_x does not change
...
@@ -154,6 +159,7 @@ class GCode(object):
...
@@ -154,6 +159,7 @@ class GCode(object):
# current abs X in machine current coordinate system: current_x - offset_x
# current abs X in machine current coordinate system: current_x - offset_x
filament_length
=
None
filament_length
=
None
filament_length_multi
=
[
0
]
duration
=
None
duration
=
None
xmin
=
None
xmin
=
None
xmax
=
None
xmax
=
None
...
@@ -186,6 +192,10 @@ class GCode(object):
...
@@ -186,6 +192,10 @@ class GCode(object):
return
self
.
current_e
-
self
.
offset_e
return
self
.
current_e
-
self
.
offset_e
abs_e
=
property
(
_get_abs_e
)
abs_e
=
property
(
_get_abs_e
)
def
_get_abs_e_multi
(
self
,
i
):
return
self
.
current_e_multi
[
i
]
-
self
.
offset_e_multi
[
i
]
abs_e
=
property
(
_get_abs_e
)
def
_get_abs_pos
(
self
):
def
_get_abs_pos
(
self
):
return
(
self
.
abs_x
,
self
.
abs_y
,
self
.
abs_z
)
return
(
self
.
abs_x
,
self
.
abs_y
,
self
.
abs_z
)
abs_pos
=
property
(
_get_abs_pos
)
abs_pos
=
property
(
_get_abs_pos
)
...
@@ -329,6 +339,11 @@ class GCode(object):
...
@@ -329,6 +339,11 @@ class GCode(object):
total_e
=
self
.
total_e
total_e
=
self
.
total_e
max_e
=
self
.
max_e
max_e
=
self
.
max_e
current_e_multi
=
self
.
current_e_multi
[
current_tool
]
offset_e_multi
=
self
.
offset_e_multi
[
current_tool
]
total_e_multi
=
self
.
total_e_multi
[
current_tool
]
max_e_multi
=
self
.
max_e_multi
[
current_tool
]
# Store this one out of the build_layers scope for efficiency
# Store this one out of the build_layers scope for efficiency
cur_layer_has_extrusion
=
False
cur_layer_has_extrusion
=
False
...
@@ -408,6 +423,16 @@ class GCode(object):
...
@@ -408,6 +423,16 @@ class GCode(object):
relative_e
=
True
relative_e
=
True
elif
line
.
command
[
0
]
==
"T"
:
elif
line
.
command
[
0
]
==
"T"
:
current_tool
=
int
(
line
.
command
[
1
:])
current_tool
=
int
(
line
.
command
[
1
:])
while
(
current_tool
+
1
>
len
(
self
.
current_e_multi
)):
self
.
current_e_multi
+=
[
0
]
self
.
offset_e_multi
+=
[
0
]
self
.
total_e_multi
+=
[
0
]
self
.
max_e_multi
+=
[
0
]
current_e_multi
=
self
.
current_e_multi
[
current_tool
]
offset_e_multi
=
self
.
offset_e_multi
[
current_tool
]
total_e_multi
=
self
.
total_e_multi
[
current_tool
]
max_e_multi
=
self
.
max_e_multi
[
current_tool
]
if
line
.
command
[
0
]
==
"G"
:
if
line
.
command
[
0
]
==
"G"
:
parse_coordinates
(
line
,
split_raw
,
imperial
)
parse_coordinates
(
line
,
split_raw
,
imperial
)
...
@@ -462,15 +487,28 @@ class GCode(object):
...
@@ -462,15 +487,28 @@ class GCode(object):
line
.
extruding
=
line
.
e
>
0
line
.
extruding
=
line
.
e
>
0
total_e
+=
line
.
e
total_e
+=
line
.
e
current_e
+=
line
.
e
current_e
+=
line
.
e
total_e_multi
+=
line
.
e
current_e_multi
+=
line
.
e
else
:
else
:
new_e
=
line
.
e
+
offset_e
new_e
=
line
.
e
+
offset_e
line
.
extruding
=
new_e
>
current_e
line
.
extruding
=
new_e
>
current_e
total_e
+=
new_e
-
current_e
total_e
+=
new_e
-
current_e
current_e
=
new_e
current_e
=
new_e
new_e_multi
=
line
.
e
+
offset_e_multi
total_e_multi
+=
new_e_multi
-
current_e_multi
current_e_multi
=
new_e_multi
max_e
=
max
(
max_e
,
total_e
)
max_e
=
max
(
max_e
,
total_e
)
max_e_multi
=
max
(
max_e_multi
,
total_e_multi
)
cur_layer_has_extrusion
|=
line
.
extruding
cur_layer_has_extrusion
|=
line
.
extruding
elif
line
.
command
==
"G92"
:
elif
line
.
command
==
"G92"
:
offset_e
=
current_e
-
line
.
e
offset_e
=
current_e
-
line
.
e
offset_e_multi
=
current_e_multi
-
line
.
e
self
.
current_e_multi
[
current_tool
]
=
current_e_multi
self
.
offset_e_multi
[
current_tool
]
=
offset_e_multi
self
.
max_e_multi
[
current_tool
]
=
max_e_multi
self
.
total_e_multi
[
current_tool
]
=
total_e_multi
# # Create layers and perform global computations
# # Create layers and perform global computations
if
build_layers
:
if
build_layers
:
...
@@ -623,11 +661,15 @@ class GCode(object):
...
@@ -623,11 +661,15 @@ class GCode(object):
self
.
offset_x
=
offset_x
self
.
offset_x
=
offset_x
self
.
offset_y
=
offset_y
self
.
offset_y
=
offset_y
self
.
offset_z
=
offset_z
self
.
offset_z
=
offset_z
self
.
current_e
=
current_e
self
.
current_e
=
current_e
self
.
offset_e
=
offset_e
self
.
offset_e
=
offset_e
self
.
max_e
=
max_e
self
.
max_e
=
max_e
self
.
total_e
=
total_e
self
.
total_e
=
total_e
self
.
current_e_multi
[
current_tool
]
=
current_e_multi
self
.
offset_e_multi
[
current_tool
]
=
offset_e_multi
self
.
max_e_multi
[
current_tool
]
=
max_e_multi
self
.
total_e_multi
[
current_tool
]
=
total_e_multi
# Finalize layers
# Finalize layers
if
build_layers
:
if
build_layers
:
...
@@ -652,6 +694,11 @@ class GCode(object):
...
@@ -652,6 +694,11 @@ class GCode(object):
zmax
=
max
(
all_zs
)
zmax
=
max
(
all_zs
)
self
.
filament_length
=
self
.
max_e
self
.
filament_length
=
self
.
max_e
while
len
(
self
.
filament_length_multi
)
<
len
(
self
.
max_e_multi
):
self
.
filament_length_multi
+=
[
0
]
for
i
in
enumerate
(
self
.
max_e_multi
):
self
.
filament_length_multi
[
i
[
0
]]
=
i
[
1
]
if
self
.
filament_length
>
0
:
if
self
.
filament_length
>
0
:
self
.
xmin
=
xmin_e
if
not
math
.
isinf
(
xmin_e
)
else
0
self
.
xmin
=
xmin_e
if
not
math
.
isinf
(
xmin_e
)
else
0
...
@@ -699,6 +746,8 @@ def main():
...
@@ -699,6 +746,8 @@ def main():
zdims
=
(
gcode
.
zmin
,
gcode
.
zmax
,
gcode
.
height
)
zdims
=
(
gcode
.
zmin
,
gcode
.
zmax
,
gcode
.
height
)
print
"
\t
Z:
%0.02
f -
%0.02
f (
%0.02
f)"
%
zdims
print
"
\t
Z:
%0.02
f -
%0.02
f (
%0.02
f)"
%
zdims
print
"Filament used:
%0.02
fmm"
%
gcode
.
filament_length
print
"Filament used:
%0.02
fmm"
%
gcode
.
filament_length
for
i
in
enumerate
(
gcode
.
filament_length_multi
):
print
"E
%
d
%0.02
fmm"
%
(
i
[
0
],
i
[
1
])
print
"Number of layers:
%
d"
%
gcode
.
layers_count
print
"Number of layers:
%
d"
%
gcode
.
layers_count
print
"Estimated duration:
%
s"
%
gcode
.
estimate_duration
()[
1
]
print
"Estimated duration:
%
s"
%
gcode
.
estimate_duration
()[
1
]
...
...
printrun/pronterface.py
View file @
de535f11
...
@@ -1440,6 +1440,9 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
...
@@ -1440,6 +1440,9 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
def
output_gcode_stats
(
self
):
def
output_gcode_stats
(
self
):
gcode
=
self
.
fgcode
gcode
=
self
.
fgcode
self
.
log
(
_
(
"
%.2
fmm of filament used in this print"
)
%
gcode
.
filament_length
)
self
.
log
(
_
(
"
%.2
fmm of filament used in this print"
)
%
gcode
.
filament_length
)
if
(
len
(
gcode
.
filament_length_multi
)
>
1
):
for
i
in
enumerate
(
gcode
.
filament_length_multi
):
print
"Extruder
%
d:
%0.02
fmm"
%
(
i
[
0
],
i
[
1
])
self
.
log
(
_
(
"The print goes:"
))
self
.
log
(
_
(
"The print goes:"
))
self
.
log
(
_
(
"- from
%.2
f mm to
%.2
f mm in X and is
%.2
f mm wide"
)
%
(
gcode
.
xmin
,
gcode
.
xmax
,
gcode
.
width
))
self
.
log
(
_
(
"- from
%.2
f mm to
%.2
f mm in X and is
%.2
f mm wide"
)
%
(
gcode
.
xmin
,
gcode
.
xmax
,
gcode
.
width
))
self
.
log
(
_
(
"- from
%.2
f mm to
%.2
f mm in Y and is
%.2
f mm deep"
)
%
(
gcode
.
ymin
,
gcode
.
ymax
,
gcode
.
depth
))
self
.
log
(
_
(
"- from
%.2
f mm to
%.2
f mm in Y and is
%.2
f mm deep"
)
%
(
gcode
.
ymin
,
gcode
.
ymax
,
gcode
.
depth
))
...
...
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