Skip to content

Commit 14e7460

Browse files
committed
corrected calculation of extruded volume
1 parent a59aafc commit 14e7460

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

pyGCodeDecode/gcode_interpreter.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,11 @@ def save_summary(self, filepath: Union[Path, str]):
428428
e_end = self.blocklist[-1].get_segments()[-1].pos_end.get_vec(withExtrusion=True)[3]
429429

430430
filament_diam = self.initial_machine_setup_dict.get("filament_diam", None)
431-
e_amount = (e_end - self.initial_machine_setup_dict["E"]) * filament_diam if filament_diam is not None else None
431+
e_amount = (
432+
(e_end - self.initial_machine_setup_dict["E"]) * (np.pi * filament_diam**2 / 4)
433+
if filament_diam is not None
434+
else None
435+
)
432436

433437
summary = {
434438
"filename": str(self.filename),
@@ -523,12 +527,9 @@ def load_setup(self, filepath, printer=None):
523527
Args:
524528
filepath: (string) specify path to setup file
525529
"""
526-
import yaml
527-
from yaml import Loader
528-
529530
file = open(file=filepath)
530531

531-
setup_dict = yaml.load(file, Loader=Loader)
532+
setup_dict = yaml.load(file, Loader=yaml.Loader)
532533
if printer:
533534
self.setup_dict = setup_dict[printer]
534535
self.printer = printer
@@ -594,7 +595,7 @@ def check_initial_setup(self):
594595
f"Invalid Key: '{key}' in Setup Dictionary, check for typos. Valid keys are: {valid_keys}"
595596
)
596597

597-
# check if every required key is proivded
598+
# check if every required key is provided
598599
for key in req_keys:
599600
if key not in initial_machine_setup:
600601
raise ValueError(
@@ -608,7 +609,7 @@ def set_initial_position(self, initial_position: Union[tuple, dict], input_unit_
608609
609610
Args:
610611
initial_position: (tuple or dict) set initial position as tuple of len(4)
611-
or dictionary with keys: {X, Y, Z, E} or "first" to use first occuring absolute position in GCode.
612+
or dictionary with keys: {X, Y, Z, E} or "first" to use first occurring absolute position in GCode.
612613
input_unit_system (str, optional): Wanted input unit system.
613614
Uses the one specified for the setup if None is specified.
614615

0 commit comments

Comments
 (0)