From c2f89938286bd5617a59bdb12b2674a8547158d5 Mon Sep 17 00:00:00 2001 From: "lane.wei" Date: Tue, 29 Aug 2023 21:15:49 +0800 Subject: [PATCH] ENH: CLI: add support of rotate JIRA: STUDIO-4183 Change-Id: I091cc3142ce867d2ac75ba27b3cb2e4e569c9681 --- src/BambuStudio.cpp | 48 +++++++++++++++++++++++++---------- src/libslic3r/PrintConfig.cpp | 20 +++++++-------- 2 files changed, 44 insertions(+), 24 deletions(-) diff --git a/src/BambuStudio.cpp b/src/BambuStudio.cpp index a5ebe21ab9..8c23322e7f 100644 --- a/src/BambuStudio.cpp +++ b/src/BambuStudio.cpp @@ -2012,18 +2012,35 @@ int CLI::run(int argc, char **argv) } } else if (opt_key == "orient") { - for (auto& model : m_models) - for (ModelObject* o : model.objects) - { - // coconut: always orient instance instead of object - for (ModelInstance* mi : o->instances) + //BBS: orient 0 means disable, 1 means force orient, others means auto + int orient_option = m_config.option("orient")->value; + + if (orient_option == 0) + { + orients_requirement.clear(); + for (auto& model : m_models) + for (ModelObject* o : model.objects) { - orientation::orient(mi); + orients_requirement.insert(std::pair(o->id().id, false)); + BOOST_LOG_TRIVIAL(info) << "object "<name <<", id :" << o->id().id << ", no need to orient when setting orient to 0\n"; } - BOOST_LOG_TRIVIAL(info) << "orient object, name=" << o->name <<",id="<id().id<id().id] = false; - } + } + else if (orient_option == 1) + { + //force orient + orients_requirement.clear(); + for (auto& model : m_models) + for (ModelObject* o : model.objects) + { + orients_requirement.insert(std::pair(o->id().id, true)); + BOOST_LOG_TRIVIAL(info) << "object "<name <<", id :" << o->id().id << ", need to orient when setting orient to 1\n"; + } + } + else + { + //auto arrange, keep the original logic + } + BOOST_LOG_TRIVIAL(info) << boost::format("orient_option %1%")%orient_option; } else if (opt_key == "copy") { for (auto &model : m_models) { @@ -2783,10 +2800,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.) //BBS: current only support models on bed, 0407 sinking supported - //if (m_config.opt_bool("ensure_on_bed")) - // for (auto &model : m_models) - // for (auto &o : model.objects) - // o->ensure_on_bed(); + if (m_config.opt_bool("ensure_on_bed")) + { + BOOST_LOG_TRIVIAL(info) << "ensure_on_bed: need to ensure each object on beds"; + for (auto &model : m_models) + for (auto &o : model.objects) + o->ensure_on_bed(); + } // loop through action options bool export_to_3mf = false, load_slicedata = false, export_slicedata = false, export_slicedata_error = false; diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 94ae7c3726..19de34712f 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -5187,12 +5187,12 @@ CLITransformConfigDef::CLITransformConfigDef() def->cli_params = "count"; def->set_default_value(new ConfigOptionInt(1)); - /*def = this->add("ensure_on_bed", coBool); + def = this->add("ensure_on_bed", coBool); def->label = L("Ensure on bed"); - def->tooltip = L("Lift the object above the bed when it is partially below. Enabled by default, use --no-ensure-on-bed to disable."); - def->set_default_value(new ConfigOptionBool(true)); + def->tooltip = L("Lift the object above the bed when it is partially below. Disabled by default"); + def->set_default_value(new ConfigOptionBool(false)); - def = this->add("copy", coInt); + /*def = this->add("copy", coInt); def->label = L("Copy"); def->tooltip =L("Duplicate copies of model"); def->min = 1; @@ -5212,18 +5212,18 @@ CLITransformConfigDef::CLITransformConfigDef() def->tooltip = L("Convert the units of model"); def->set_default_value(new ConfigOptionBool(false)); - def = this->add("orient", coBool); - def->label = L("Orient"); - def->tooltip = L("Orient the model"); + def = this->add("orient", coInt); + def->label = L("Orient Options"); + def->tooltip = L("Orient options: 0-disable, 1-enable, others-auto"); //def->cli = "orient|o"; - def->set_default_value(new ConfigOptionBool(false)); + def->set_default_value(new ConfigOptionInt(0)); /*def = this->add("repair", coBool); def->label = L("Repair"); def->tooltip = L("Repair the model's meshes if it is non-manifold mesh"); def->set_default_value(new ConfigOptionBool(false));*/ - /*def = this->add("rotate", coFloat); + def = this->add("rotate", coFloat); def->label = L("Rotate"); def->tooltip = L("Rotation angle around the Z axis in degrees."); def->set_default_value(new ConfigOptionFloat(0)); @@ -5236,7 +5236,7 @@ CLITransformConfigDef::CLITransformConfigDef() def = this->add("rotate_y", coFloat); def->label = L("Rotate around Y"); def->tooltip = L("Rotation angle around the Y axis in degrees."); - def->set_default_value(new ConfigOptionFloat(0));*/ + def->set_default_value(new ConfigOptionFloat(0)); def = this->add("scale", coFloat); def->label = L("Scale");