mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-15 11:51:33 +00:00
Fix uninitialised object ids in "; printing object" comments (#16115)
Object and copy ids were only assigned in set_object_info(), which runs only for Klipper, Marlin and RRF with Exclude objects on. Every other printer, Bambu included, printed an uninitialized object id and labeled every copy as copy 0. The numbering now runs on every export, so the labels are stable and unique on all printers. Output for Klipper, Marlin and RRF with Exclude objects on is unchanged. The label test covers Marlin, Klipper and Repetier, plus a BBL row that checks each copy gets its own M624/M625 skip block. Co-authored-by: raistlin7447 <kris.austin@gmail.com>
This commit is contained in:
co-authored by
raistlin7447
parent
e028476d2a
commit
ae138090f1
+20
-9
@@ -4201,6 +4201,8 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
||||
|
||||
file.write_format("; EXECUTABLE_BLOCK_START\n");
|
||||
|
||||
// Set for every printer, as the object label comments use these ids too.
|
||||
assign_object_label_ids(print);
|
||||
// SoftFever
|
||||
if( m_enable_exclude_object)
|
||||
file.write(set_object_info(&print));
|
||||
@@ -11055,15 +11057,30 @@ inline std::string polygon_to_string(const Polygon &polygon, Print *print, bool
|
||||
gcode << "]";
|
||||
return gcode.str();
|
||||
}
|
||||
// this function iterator PrintObject and assign a seqential id to each object.
|
||||
// this id is used to generate unique object id for each object.
|
||||
// Numbers the objects, and their instances both within each object (id) and across the print
|
||||
// (unique_id). The "; printing object" comments and the exclude-object commands label objects with these ids.
|
||||
void GCode::assign_object_label_ids(Print &print)
|
||||
{
|
||||
m_instance_names.clear();
|
||||
size_t object_id = 0;
|
||||
size_t unique_id = 0;
|
||||
for (PrintObject *object : print.objects()) {
|
||||
object->set_id(object_id++);
|
||||
size_t inst_id = 0;
|
||||
for (PrintInstance &inst : object->instances()) {
|
||||
inst.id = inst_id++;
|
||||
inst.unique_id = unique_id++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Writes the exclude-object definitions for the ids assign_object_label_ids() set.
|
||||
std::string GCode::set_object_info(Print *print) {
|
||||
const auto gflavor = print->config().gcode_flavor.value;
|
||||
if (print->is_BBL_printer() ||
|
||||
(gflavor != gcfKlipper && gflavor != gcfMarlinLegacy && gflavor != gcfMarlinFirmware && gflavor != gcfRepRapFirmware))
|
||||
return "";
|
||||
std::ostringstream gcode;
|
||||
size_t object_id = 0;
|
||||
// Orca: check if we are in pa calib mode
|
||||
if (print->calib_mode() == CalibMode::Calib_PA_Pattern) {
|
||||
BoundingBoxf bbox_bed(print->config().printable_area.values);
|
||||
@@ -11079,14 +11096,8 @@ std::string GCode::set_object_info(Print *print) {
|
||||
} else if (print->calib_mode() == CalibMode::Calib_PA_Line) {
|
||||
// PA_Line has only one object, no EXCLUDE_OBJECT_DEFINE needed
|
||||
} else {
|
||||
size_t unique_id = 0;
|
||||
m_instance_names.clear();
|
||||
for (PrintObject* object : print->objects()) {
|
||||
object->set_id(object_id++);
|
||||
size_t inst_id = 0;
|
||||
for (PrintInstance& inst : object->instances()) {
|
||||
inst.unique_id = unique_id++;
|
||||
inst.id = inst_id++;
|
||||
// Outlines are in plate coordinates. On a belt printer that is the frame after
|
||||
// the slicing rotation has been undone and before the G-code axis remap and
|
||||
// machine-frame shear: where the object stands on the belt, which is what an
|
||||
|
||||
Reference in New Issue
Block a user