mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-31 07:02:02 +08:00
Add G92 at the start of every object
This commit is contained in:
parent
0894ac6d72
commit
d556969b2b
@ -2806,7 +2806,7 @@ std::string GCodeGenerator::change_layer(
|
||||
gcode += m_writer.update_progress(++ m_layer_index, m_layer_count);
|
||||
|
||||
if (m_writer.multiple_extruders) {
|
||||
gcode += m_label_objects.maybe_change_instance();
|
||||
gcode += m_label_objects.maybe_change_instance(m_writer);
|
||||
}
|
||||
|
||||
if (!EXTRUDER_CONFIG(travel_ramping_lift) && EXTRUDER_CONFIG(retract_layer_change)) {
|
||||
@ -3149,13 +3149,13 @@ std::string GCodeGenerator::_extrude(
|
||||
|
||||
const bool has_active_instance{m_label_objects.has_active_instance()};
|
||||
if (m_writer.multiple_extruders && has_active_instance) {
|
||||
gcode += m_label_objects.maybe_change_instance();
|
||||
gcode += m_label_objects.maybe_change_instance(m_writer);
|
||||
}
|
||||
|
||||
if (!m_current_layer_first_position) {
|
||||
const Vec3crd point = to_3d(path.front().point, scaled(this->m_last_layer_z));
|
||||
gcode += this->travel_to_first_position(point, unscaled(point.z()), [&](){
|
||||
return m_writer.multiple_extruders ? "" : m_label_objects.maybe_change_instance();
|
||||
return m_writer.multiple_extruders ? "" : m_label_objects.maybe_change_instance(m_writer);
|
||||
});
|
||||
} else {
|
||||
// go to first point of extrusion path
|
||||
@ -3163,7 +3163,7 @@ std::string GCodeGenerator::_extrude(
|
||||
const double z = this->m_last_layer_z;
|
||||
const std::string comment{"move to print after unknown position"};
|
||||
gcode += this->retract_and_wipe();
|
||||
gcode += m_writer.multiple_extruders ? "" : m_label_objects.maybe_change_instance();
|
||||
gcode += m_writer.multiple_extruders ? "" : m_label_objects.maybe_change_instance(m_writer);
|
||||
gcode += this->m_writer.travel_to_xy(this->point_to_gcode(path.front().point), comment);
|
||||
gcode += this->m_writer.get_travel_to_z_gcode(z, comment);
|
||||
} else if ( this->last_position != path.front().point) {
|
||||
@ -3172,7 +3172,7 @@ std::string GCodeGenerator::_extrude(
|
||||
comment += description_bridge;
|
||||
comment += " point";
|
||||
const std::string travel_gcode{this->travel_to(*this->last_position, path.front().point, path_attr.role, comment, [&](){
|
||||
return m_writer.multiple_extruders ? "" : m_label_objects.maybe_change_instance();
|
||||
return m_writer.multiple_extruders ? "" : m_label_objects.maybe_change_instance(m_writer);
|
||||
})};
|
||||
gcode += travel_gcode;
|
||||
}
|
||||
@ -3187,7 +3187,7 @@ std::string GCodeGenerator::_extrude(
|
||||
}
|
||||
|
||||
if (m_writer.multiple_extruders && !has_active_instance) {
|
||||
gcode += m_label_objects.maybe_change_instance();
|
||||
gcode += m_label_objects.maybe_change_instance(m_writer);
|
||||
}
|
||||
|
||||
if (!m_pending_pre_extrusion_gcode.empty()) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "LabelObjects.hpp"
|
||||
|
||||
#include "ClipperUtils.hpp"
|
||||
#include "GCode/GCodeWriter.hpp"
|
||||
#include "Model.hpp"
|
||||
#include "Print.hpp"
|
||||
#include "TriangleMeshSlicer.hpp"
|
||||
@ -119,10 +120,13 @@ bool LabelObjects::update(const PrintInstance *instance) {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string LabelObjects::maybe_start_instance() {
|
||||
std::string LabelObjects::maybe_start_instance(GCodeWriter& writer) {
|
||||
if (current_instance == nullptr && last_operation_instance != nullptr) {
|
||||
current_instance = last_operation_instance;
|
||||
return this->start_object(*current_instance, LabelObjects::IncludeName::No);
|
||||
|
||||
std::string result{this->start_object(*current_instance, LabelObjects::IncludeName::No)};
|
||||
result += writer.reset_e(true);
|
||||
return result;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@ -136,12 +140,12 @@ std::string LabelObjects::maybe_stop_instance() {
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string LabelObjects::maybe_change_instance() {
|
||||
std::string LabelObjects::maybe_change_instance(GCodeWriter& writer) {
|
||||
if (last_operation_instance != current_instance) {
|
||||
const std::string stop_instance_gcode{this->maybe_stop_instance()};
|
||||
// Be carefull with refactoring: this->maybe_stop_instance() + this->maybe_start_instance()
|
||||
// may not be evaluated in order. The order is indeed undefined!
|
||||
return stop_instance_gcode + this->maybe_start_instance();
|
||||
return stop_instance_gcode + this->maybe_start_instance(writer);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ enum GCodeFlavor : unsigned char;
|
||||
enum class LabelObjectsStyle;
|
||||
struct PrintInstance;
|
||||
class Print;
|
||||
|
||||
class GCodeWriter;
|
||||
|
||||
namespace GCode {
|
||||
|
||||
@ -25,11 +25,11 @@ public:
|
||||
|
||||
bool update(const PrintInstance *instance);
|
||||
|
||||
std::string maybe_start_instance();
|
||||
std::string maybe_start_instance(GCodeWriter& writer);
|
||||
|
||||
std::string maybe_stop_instance();
|
||||
|
||||
std::string maybe_change_instance();
|
||||
std::string maybe_change_instance(GCodeWriter& writer);
|
||||
|
||||
bool has_active_instance();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user