diff --git a/src/PrusaSlicer.cpp b/src/PrusaSlicer.cpp index b3e6841c9d..21b161456f 100644 --- a/src/PrusaSlicer.cpp +++ b/src/PrusaSlicer.cpp @@ -258,6 +258,7 @@ int CLI::run(int argc, char **argv) Points bed = get_bed_shape(m_print_config); ArrangeParams arrange_cfg; arrange_cfg.min_obj_distance = scaled(min_object_distance(m_print_config)); + bool user_ensure_on_bed = true; for (auto const &opt_key : m_transforms) { if (opt_key == "merge") { @@ -330,6 +331,10 @@ int CLI::run(int argc, char **argv) } } else if (opt_key == "dont_arrange") { // do nothing - this option alters other transform options + } else if (opt_key == "dont_ensure_on_bed") { + // Remember that we saw this so we don't lift objects from the bed + // after the other transformations are processed. + user_ensure_on_bed = false; } else if (opt_key == "rotate") { for (auto &model : m_models) for (auto &o : model.objects) @@ -432,6 +437,13 @@ int CLI::run(int argc, char **argv) } } + // All transforms have been dealt with. Now ensure that the objects are on bed. + // (Unless the user said otherwise.) + if (user_ensure_on_bed) + for (auto &model : m_models) + for (auto &o : model.objects) + o->ensure_on_bed(); + // loop through action options for (auto const &opt_key : m_actions) { if (opt_key == "help") { diff --git a/src/libslic3r/Model.cpp b/src/libslic3r/Model.cpp index e6006ef584..ba743f49ca 100644 --- a/src/libslic3r/Model.cpp +++ b/src/libslic3r/Model.cpp @@ -1745,18 +1745,15 @@ void ModelVolume::scale(const Vec3d& scaling_factors) void ModelObject::scale_to_fit(const Vec3d &size) { -/* - BoundingBoxf3 instance_bounding_box(size_t instance_idx, bool dont_translate = false) const; Vec3d orig_size = this->bounding_box().size(); - float factor = fminf( - size.x / orig_size.x, - fminf( - size.y / orig_size.y, - size.z / orig_size.z + double factor = std::min( + size.x() / orig_size.x(), + std::min( + size.y() / orig_size.y(), + size.z() / orig_size.z() ) ); this->scale(factor); -*/ } void ModelVolume::assign_new_unique_ids_recursive() diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 5128431102..16c16f038e 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -4154,6 +4154,10 @@ CLITransformConfigDef::CLITransformConfigDef() def->label = L("Don't arrange"); def->tooltip = L("Do not rearrange the given models before merging and keep their original XY coordinates."); + def = this->add("dont_ensure_on_bed", coBool); + def->label = L("Don't ensure on bed"); + def->tooltip = L("Do not lift the object above the bed when it is partially below."); + def = this->add("duplicate", coInt); def->label = L("Duplicate"); def->tooltip =L("Multiply copies by this factor.");