From 4c622c504f8f7c479a8368f7672ec96426391554 Mon Sep 17 00:00:00 2001 From: Chow Loong Jin Date: Wed, 13 Apr 2016 00:04:49 +0800 Subject: [PATCH] Account for travel moves in elapsed_time --- xs/src/libslic3r/GCode.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/xs/src/libslic3r/GCode.cpp b/xs/src/libslic3r/GCode.cpp index 70911e0fb..c57f6a675 100644 --- a/xs/src/libslic3r/GCode.cpp +++ b/xs/src/libslic3r/GCode.cpp @@ -629,9 +629,17 @@ GCode::travel_to(const Point &point, ExtrusionRole role, std::string comment) // use G1 because we rely on paths being straight (G0 may make round paths) Lines lines = travel.lines(); - for (Lines::const_iterator line = lines.begin(); line != lines.end(); ++line) - gcode += this->writer.travel_to_xy(this->point_to_gcode(line->b), comment); - + double path_length = 0; + for (Lines::const_iterator line = lines.begin(); line != lines.end(); ++line) { + const double line_length = line->length() * SCALING_FACTOR; + path_length += line_length; + + gcode += this->writer.travel_to_xy(this->point_to_gcode(line->b), comment); + } + + if (this->config.cooling) + this->elapsed_time += path_length / this->config.get_abs_value("travel_speed"); + return gcode; }