mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-15 08:15:56 +08:00
#495 Add bounding_box to placeholders
This commit is contained in:
parent
72dd10eba4
commit
7c80b3178d
@ -1322,7 +1322,6 @@ void GCode::_do_export(Print &print, FILE *file)
|
|||||||
_write_format(file, "; first layer extrusion width = %.2fmm\n", region->flow(frPerimeter, first_layer_height, false, true, -1., *first_object).width);
|
_write_format(file, "; first layer extrusion width = %.2fmm\n", region->flow(frPerimeter, first_layer_height, false, true, -1., *first_object).width);
|
||||||
_write_format(file, "\n");
|
_write_format(file, "\n");
|
||||||
}
|
}
|
||||||
if (this->config().gcode_label_objects) {
|
|
||||||
BoundingBoxf3 global_bounding_box;
|
BoundingBoxf3 global_bounding_box;
|
||||||
for (PrintObject *print_object : print.objects()) {
|
for (PrintObject *print_object : print.objects()) {
|
||||||
this->m_ordered_objects.push_back(print_object);
|
this->m_ordered_objects.push_back(print_object);
|
||||||
@ -1340,22 +1339,25 @@ void GCode::_do_export(Print &print, FILE *file)
|
|||||||
} else {
|
} else {
|
||||||
global_bounding_box.merge(m_bounding_box);
|
global_bounding_box.merge(m_bounding_box);
|
||||||
}
|
}
|
||||||
|
if (this->config().gcode_label_objects) {
|
||||||
_write_format(file, "; object:{\"name\":\"%s\",\"id\":\"%s id:%d copy %d\",\"object_center\":[%f,%f,%f],\"boundingbox_center\":[%f,%f,%f],\"boundingbox_size\":[%f,%f,%f]}\n",
|
_write_format(file, "; object:{\"name\":\"%s\",\"id\":\"%s id:%d copy %d\",\"object_center\":[%f,%f,%f],\"boundingbox_center\":[%f,%f,%f],\"boundingbox_size\":[%f,%f,%f]}\n",
|
||||||
object_name.c_str(), print_object->model_object()->name.c_str(), this->m_ordered_objects.size() - 1, copy_id,
|
object_name.c_str(), print_object->model_object()->name.c_str(), this->m_ordered_objects.size() - 1, copy_id,
|
||||||
m_bounding_box.center().x(), m_bounding_box.center().y(), 0.,
|
m_bounding_box.center().x(), m_bounding_box.center().y(), 0.,
|
||||||
m_bounding_box.center().x(), m_bounding_box.center().y(), m_bounding_box.center().z(),
|
m_bounding_box.center().x(), m_bounding_box.center().y(), m_bounding_box.center().z(),
|
||||||
m_bounding_box.size().x(), m_bounding_box.size().y(), m_bounding_box.size().z()
|
m_bounding_box.size().x(), m_bounding_box.size().y(), m_bounding_box.size().z()
|
||||||
);
|
);
|
||||||
|
}
|
||||||
copy_id++;
|
copy_id++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (this->config().gcode_label_objects) {
|
||||||
_write_format(file, "; plater:{\"center\":[%f,%f,%f],\"boundingbox_center\":[%f,%f,%f],\"boundingbox_size\":[%f,%f,%f]}\n",
|
_write_format(file, "; plater:{\"center\":[%f,%f,%f],\"boundingbox_center\":[%f,%f,%f],\"boundingbox_size\":[%f,%f,%f]}\n",
|
||||||
global_bounding_box.center().x(), global_bounding_box.center().y(), 0.,
|
global_bounding_box.center().x(), global_bounding_box.center().y(), 0.,
|
||||||
global_bounding_box.center().x(), global_bounding_box.center().y(), global_bounding_box.center().z(),
|
global_bounding_box.center().x(), global_bounding_box.center().y(), global_bounding_box.center().z(),
|
||||||
global_bounding_box.size().x(), global_bounding_box.size().y(), global_bounding_box.size().z()
|
global_bounding_box.size().x(), global_bounding_box.size().y(), global_bounding_box.size().z()
|
||||||
);
|
);
|
||||||
_write_format(file, "\n");
|
|
||||||
}
|
}
|
||||||
|
_write_format(file, "\n");
|
||||||
|
|
||||||
print.throw_if_canceled();
|
print.throw_if_canceled();
|
||||||
|
|
||||||
@ -1465,6 +1467,8 @@ void GCode::_do_export(Print &print, FILE *file)
|
|||||||
m_placeholder_parser.set("has_wipe_tower", has_wipe_tower);
|
m_placeholder_parser.set("has_wipe_tower", has_wipe_tower);
|
||||||
m_placeholder_parser.set("has_single_extruder_multi_material_priming", has_wipe_tower && print.config().single_extruder_multi_material_priming);
|
m_placeholder_parser.set("has_single_extruder_multi_material_priming", has_wipe_tower && print.config().single_extruder_multi_material_priming);
|
||||||
m_placeholder_parser.set("total_toolchanges", std::max(0, print.wipe_tower_data().number_of_toolchanges)); // Check for negative toolchanges (single extruder mode) and set to 0 (no tool change).
|
m_placeholder_parser.set("total_toolchanges", std::max(0, print.wipe_tower_data().number_of_toolchanges)); // Check for negative toolchanges (single extruder mode) and set to 0 (no tool change).
|
||||||
|
m_placeholder_parser.set("bounding_box", new ConfigOptionFloats({ global_bounding_box.min.x(), global_bounding_box.min.y(), global_bounding_box.max.x(), global_bounding_box.max.y() }));
|
||||||
|
|
||||||
|
|
||||||
std::string start_gcode = this->placeholder_parser_process("start_gcode", print.config().start_gcode.value, initial_extruder_id);
|
std::string start_gcode = this->placeholder_parser_process("start_gcode", print.config().start_gcode.value, initial_extruder_id);
|
||||||
// Set bed temperature if the start G-code does not contain any bed temp control G-codes.
|
// Set bed temperature if the start G-code does not contain any bed temp control G-codes.
|
||||||
|
@ -2991,7 +2991,8 @@ void PrintConfigDef::init_fff_params()
|
|||||||
"such commands will not be prepended automatically so you're free to customize "
|
"such commands will not be prepended automatically so you're free to customize "
|
||||||
"the order of heating commands and other custom actions. Note that you can use "
|
"the order of heating commands and other custom actions. Note that you can use "
|
||||||
"placeholder variables for all Slic3r settings, so you can put "
|
"placeholder variables for all Slic3r settings, so you can put "
|
||||||
"a \"M109 S[first_layer_temperature]\" command wherever you want.");
|
"a \"M109 S[first_layer_temperature]\" command wherever you want."
|
||||||
|
"\n placeholders: initial_extruder, total_layer_count, has_wipe_tower, has_single_extruder_multi_material_priming, total_toolchanges, bounding_box[minx,miny,maxx,maxy]");
|
||||||
def->multiline = true;
|
def->multiline = true;
|
||||||
def->full_width = true;
|
def->full_width = true;
|
||||||
def->height = 12;
|
def->height = 12;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user