From f75c022445384b9fd656db79395edcca6ba242a5 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Tue, 5 Nov 2019 11:16:55 +0100 Subject: [PATCH] Reworked pull request Centering model on bed, using bed shape from config (if available). #2424 thanks @luketaverne --- src/PrusaSlicer.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/PrusaSlicer.cpp b/src/PrusaSlicer.cpp index 6c6f9584f..f708679c1 100644 --- a/src/PrusaSlicer.cpp +++ b/src/PrusaSlicer.cpp @@ -167,6 +167,7 @@ int CLI::run(int argc, char **argv) // sla_print_config.apply(m_print_config, true); // Loop through transform options. + bool user_center_specified = false; for (auto const &opt_key : m_transforms) { if (opt_key == "merge") { Model m; @@ -209,6 +210,7 @@ int CLI::run(int argc, char **argv) for (auto &model : m_models) model.duplicate_objects_grid(x, y, (distance > 0) ? distance : 6); // TODO: this is not the right place for setting a default } else if (opt_key == "center") { + user_center_specified = true; for (auto &model : m_models) { model.add_default_instances(); // this affects instances: @@ -403,7 +405,9 @@ int CLI::run(int argc, char **argv) if (! m_config.opt_bool("dont_arrange")) { //FIXME make the min_object_distance configurable. model.arrange_objects(fff_print.config().min_object_distance()); - model.center_instances_around_point(m_config.option("center")->value); + model.center_instances_around_point((! user_center_specified && m_print_config.has("bed_shape")) ? + BoundingBoxf(m_print_config.opt("bed_shape")->values).center() : + m_config.option("center")->value); } if (printer_technology == ptFFF) { for (auto* mo : model.objects)