From 89dc4e1b99f836550b7683779cb1a3a5e4638909 Mon Sep 17 00:00:00 2001 From: HanifKoh <76276251+HanifKoh@users.noreply.github.com> Date: Wed, 23 Sep 2026 12:43:08 +0800 Subject: [PATCH] Add an Align to Y Axis Option to the CLI Arrange (#15836) The CLI turned "align to Y axis" on for every i3 printer with no way to opt out. With rotations forbidden the pre-rotation is the result, so every object ends up turned 90 degrees from how it was loaded. The GUI defaults the checkbox the same way for i3 printers, but lets the user untick it. Add --align-to-y-axis. When it is not given the printer-structure rule still applies, so existing calls are unchanged; the CLI's own options are filled with defaults after parsing, so the keys the user typed are remembered to tell the two apart. --- src/OrcaSlicer.cpp | 15 +++++++++++++-- src/OrcaSlicer.hpp | 4 ++++ src/libslic3r/PrintConfig.cpp | 6 ++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/OrcaSlicer.cpp b/src/OrcaSlicer.cpp index 0c9bd0b1ee..57be0595cb 100644 --- a/src/OrcaSlicer.cpp +++ b/src/OrcaSlicer.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #if defined(__linux__) || defined(__LINUX__) #include @@ -1614,6 +1615,10 @@ int CLI::run(int argc, char **argv) ConfigOptionBool* allow_rotations_option = m_config.option("allow_rotations"); if (allow_rotations_option) allow_rotations = allow_rotations_option->value; + // Only an explicit --align-to-y-axis overrides the printer-structure default. + std::optional align_to_y_axis; + if (m_given_option_keys.count("align_to_y_axis") > 0) + align_to_y_axis = m_config.opt_bool("align_to_y_axis"); ConfigOptionBool* skip_modified_gcodes_option = m_config.option("skip_modified_gcodes"); if (skip_modified_gcodes_option) @@ -5298,7 +5303,9 @@ int CLI::run(int argc, char **argv) arrange_cfg.bed_shrink_x = BED_SHRINK_SEQ_PRINT; arrange_cfg.bed_shrink_y = BED_SHRINK_SEQ_PRINT; } - if (auto printer_structure_opt = m_print_config.option>("printer_structure")) { + if (align_to_y_axis.has_value()) { + arrange_cfg.align_to_y_axis = *align_to_y_axis; + } else if (auto printer_structure_opt = m_print_config.option>("printer_structure")) { arrange_cfg.align_to_y_axis = (printer_structure_opt->value == PrinterStructure::psI3); } @@ -5748,7 +5755,9 @@ int CLI::run(int argc, char **argv) arrange_cfg.bed_shrink_x = BED_SHRINK_SEQ_PRINT; arrange_cfg.bed_shrink_y = BED_SHRINK_SEQ_PRINT; } - if (auto printer_structure_opt = m_print_config.option>("printer_structure")) { + if (align_to_y_axis.has_value()) { + arrange_cfg.align_to_y_axis = *align_to_y_axis; + } else if (auto printer_structure_opt = m_print_config.option>("printer_structure")) { arrange_cfg.align_to_y_axis = (printer_structure_opt->value == PrinterStructure::psI3); } @@ -7943,6 +7952,8 @@ bool CLI::setup(int argc, char **argv) for (std::string &input_file : m_input_files) input_file = resolve_cli_input_path(input_file); + m_given_option_keys.insert(opt_order.begin(), opt_order.end()); + // Parse actions and transform options. for (auto const &opt_key : opt_order) { if (cli_actions_config_def.has(opt_key)) diff --git a/src/OrcaSlicer.hpp b/src/OrcaSlicer.hpp index e6aada821f..380607e95f 100644 --- a/src/OrcaSlicer.hpp +++ b/src/OrcaSlicer.hpp @@ -1,6 +1,8 @@ #ifndef SLIC3R_HPP #define SLIC3R_HPP +#include + #include "libslic3r/Config.hpp" #include "libslic3r/Model.hpp" @@ -113,6 +115,8 @@ private: std::vector m_input_files; std::vector m_actions; std::vector m_transforms; + // Options the user typed; setup() fills the CLI's own options with defaults afterwards. + std::set m_given_option_keys; std::vector m_models; bool setup(int argc, char **argv); diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 92e7067ae5..bf7a651dcc 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -12347,6 +12347,12 @@ CLIMiscConfigDef::CLIMiscConfigDef() def->tooltip = L("If enabled, Arrange will allow rotation when placing objects."); def->set_default_value(new ConfigOptionBool(true)); + def = this->add("align_to_y_axis", coBool); + def->label = L("Align to Y axis when arranging"); + def->tooltip = L("If enabled, Arrange will turn each object so its long side runs along the Y axis before placing it. " + "When not given, it is on for i3 printers and off for the others, as in the GUI."); + def->set_default_value(new ConfigOptionBool(false)); + def = this->add("avoid_extrusion_cali_region", coBool); def->label = L("Avoid extrusion calibrate region when arranging"); def->tooltip = L("If enabled, Arrange will avoid extrusion calibrate region when placing objects.");