Skip to content

Commit

Permalink
fix label object: end an object before layer change if multiple objects.
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Aug 4, 2024
1 parent a207d17 commit 842cec9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/libslic3r/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3176,10 +3176,16 @@ LayerResult GCodeGenerator::process_layer(
m_enable_loop_clipping = !enable;
}


std::string gcode;
assert(is_decimal_separator_point()); // for the sprintfs

// unless this layer print only this object, it needs to end here so the layer change won't be skipped.
if (layers.size() > 1
|| layers.front().object()->id() != m_gcode_label_objects_last_object_id
|| layers.front().object()->instances().size() > 1) {
ensure_end_object_change_labels(gcode);
}

// add tag for processor
gcode += ";" + GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Layer_Change) + "\n";
// export layer z
Expand Down Expand Up @@ -3211,6 +3217,7 @@ LayerResult GCodeGenerator::process_layer(
print.config().before_layer_gcode.value, m_writer.tool()->id(), &config)
+ "\n";
}

// print z move to next layer UNLESS (HACK for superslicer#1775)
// if it's going to the first layer, then we may want to delay the move in these condition:
// there is no "after layer change gcode" and it's the first move from the unknown
Expand Down Expand Up @@ -3587,8 +3594,8 @@ void GCodeGenerator::process_layer_single_object(
m_avoid_crossing_perimeters.use_external_mp_once();
m_current_instance = next_instance;
this->set_origin(unscale(offset));
assert(!m_gcode_label_objects_in_session);
m_gcode_label_objects_start = m_label_objects.start_object(instance, GCode::LabelObjects::IncludeName::No);
m_gcode_label_objects_last_object_id = print_object.id();

if (!print_args.print_instance.print_object.config().object_gcode.value.empty()) {
DynamicConfig config;
Expand Down
1 change: 1 addition & 0 deletions src/libslic3r/GCode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ class GCodeGenerator : ExtrusionVisitorConst {
std::string m_gcode_label_objects_start;
std::string m_gcode_label_objects_end;
bool m_gcode_label_objects_in_session = false;
ObjectID m_gcode_label_objects_last_object_id = -1;
void _add_object_change_labels(std::string &gcode);
void ensure_end_object_change_labels(std::string &gcode);

Expand Down

0 comments on commit 842cec9

Please sign in to comment.