diff --git a/src/BambuStudio.cpp b/src/BambuStudio.cpp index 6650c64ca..2ad2694c9 100644 --- a/src/BambuStudio.cpp +++ b/src/BambuStudio.cpp @@ -122,6 +122,7 @@ std::map cli_errors = { {CLI_PRINTABLE_SIZE_REDUCED, "The selected printer's bed size is smaller than the bed size used in the print profile."}, {CLI_OBJECT_ARRANGE_FAILED, "An error occurred when auto-arranging object(s)."}, {CLI_OBJECT_ORIENT_FAILED, "An error occurred when auto-orienting object(s)."}, + {CLI_MODIFIED_PARAMS_TO_PRINTER, "Found modified parameter in printer preset in the 3mf file, which should not be changed."}, {CLI_NO_SUITABLE_OBJECTS, "An empty plate was found. Please check that all plates are not empty in Bambu Studio before uploading."}, {CLI_VALIDATE_ERROR, "There are some incorrect slicing parameters in the 3mf. Please verify the slicing of all plates in Bambu Studio before uploading."}, {CLI_OBJECTS_PARTLY_INSIDE, "Some objects are located over the boundary of the heated bed."}, @@ -595,6 +596,7 @@ int CLI::run(int argc, char **argv) int old_printable_height = 0, old_printable_width = 0, old_printable_depth = 0; Pointfs old_printable_area, old_exclude_area; float old_max_radius = 0.f, old_height_to_rod = 0.f, old_height_to_lid = 0.f; + std::vector old_max_layer_height, old_min_layer_height; std::string outfile_dir = m_config.opt_string("outputdir", true); const std::vector &load_configs = m_config.option("load_settings", true)->values; const std::vector &uptodate_configs = m_config.option("uptodate_settings", true)->values; @@ -884,6 +886,10 @@ int CLI::run(int argc, char **argv) old_height_to_lid = config.opt_float("extruder_clearance_height_to_lid"); if (config.option("extruder_clearance_max_radius")) old_max_radius = config.opt_float("extruder_clearance_max_radius"); + if (config.option("max_layer_height")) + old_max_layer_height = config.option("max_layer_height")->values; + if (config.option("min_layer_height")) + old_min_layer_height = config.option("min_layer_height")->values; BOOST_LOG_TRIVIAL(info) << boost::format("old printable size from 3mf: {%1%, %2%, %3%}")%old_printable_width %old_printable_depth %old_printable_height; BOOST_LOG_TRIVIAL(info) << boost::format("old extruder_clearance_height_to_rod %1%, extruder_clearance_height_to_lid %2%, extruder_clearance_max_radius %3%}")%old_height_to_rod %old_height_to_lid %old_max_radius; } @@ -1302,7 +1308,7 @@ int CLI::run(int argc, char **argv) record_exit_reson(outfile_dir, ret, 0, cli_errors[ret], sliced_info); flush_and_exit(ret); } - int orig_printable_width, orig_printable_depth, orig_printable_height; + int orig_printable_width = 0, orig_printable_depth = 0, orig_printable_height = 0; Pointfs orig_printable_area; orig_printable_area = config.option("printable_area", true)->values; if (orig_printable_area.size() >= 4) { @@ -1318,8 +1324,38 @@ int CLI::run(int argc, char **argv) { std::string error_str = (boost::format("Invalid printable size {%1%, %2%, %3%} exceeds the default size.")%old_printable_width %old_printable_depth %old_printable_height).str(); BOOST_LOG_TRIVIAL(error) << error_str; - record_exit_reson(outfile_dir, CLI_INVALID_VALUES_IN_3MF, 0, error_str, sliced_info); - flush_and_exit(CLI_INVALID_VALUES_IN_3MF); + record_exit_reson(outfile_dir, CLI_MODIFIED_PARAMS_TO_PRINTER, 0, error_str, sliced_info); + flush_and_exit(CLI_MODIFIED_PARAMS_TO_PRINTER); + } + } + + std::vector orig_max_layer_height, orig_min_layer_height; + if (config.option("max_layer_height")) + orig_max_layer_height = config.option("max_layer_height")->values; + if (config.option("min_layer_height")) + orig_min_layer_height = config.option("min_layer_height")->values; + BOOST_LOG_TRIVIAL(info) << __FUNCTION__<< boost::format(":%1%, check max and min layer height: old_min_layer_height size %2%, orig_min_layer_height size %3%, old_max_layer_height size %4%, orig_max_layer_height size %5%") + %__LINE__ %old_min_layer_height.size() %orig_min_layer_height.size() %old_max_layer_height.size() %orig_max_layer_height.size(); + if ((orig_min_layer_height.size() > 0) + && (orig_max_layer_height.size() == old_max_layer_height.size()) && (orig_min_layer_height.size() == old_min_layer_height.size()) + && (orig_max_layer_height.size() == orig_min_layer_height.size())) + { + for (size_t index = 0; index < orig_min_layer_height.size(); index++) + { + if (old_min_layer_height[index] < orig_min_layer_height[index]) + { + std::string error_str = (boost::format("Nozzle %1%'s min layer height limits %2% exceeds the default size %3%.")%(index+1) %old_min_layer_height[index] %orig_min_layer_height[index]).str(); + BOOST_LOG_TRIVIAL(error) << error_str; + record_exit_reson(outfile_dir, CLI_MODIFIED_PARAMS_TO_PRINTER, 0, error_str, sliced_info); + flush_and_exit(CLI_MODIFIED_PARAMS_TO_PRINTER); + } + else if (old_max_layer_height[index] > orig_max_layer_height[index]) + { + std::string error_str = (boost::format("Nozzle %1%'s max layer height limits %2% exceeds the default size %3%.")%(index+1) %old_max_layer_height[index] %orig_max_layer_height[index] ).str(); + BOOST_LOG_TRIVIAL(error) << error_str; + record_exit_reson(outfile_dir, CLI_MODIFIED_PARAMS_TO_PRINTER, 0, error_str, sliced_info); + flush_and_exit(CLI_MODIFIED_PARAMS_TO_PRINTER); + } } } upward_compatible_printers = config.option("upward_compatible_machine", true)->values; diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index de1adc950..8de984edd 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -1238,14 +1238,14 @@ StringObjectException Print::validate(StringObjectException *warning, Polygons* if (layer_height > max_layer_height_from_nozzle || layer_height < min_layer_height_from_nozzle) { - return { L("Layer height cannot exceed the limit in Printer Settings -> Extruder -> Layer height limits"), object, "layer_height" }; + return { L("Layer height cannot exceed the limit in Printer Settings -> Extruder -> Layer height limits"), object, "layer_height", STRING_EXCEPT_LAYER_HEIGHT_EXCEEDS_LIMIT }; } for (auto range : object->m_model_object->layer_config_ranges) { double range_layer_height = range.second.opt_float("layer_height"); if (range_layer_height > max_layer_height_from_nozzle || range_layer_height < min_layer_height_from_nozzle) - return { L("Layer height cannot exceed the limit in Printer Settings -> Extruder -> Layer height limits"), nullptr, "layer_height" }; + return { L("Layer height cannot exceed the limit in Printer Settings -> Extruder -> Layer height limits"), nullptr, "layer_height", STRING_EXCEPT_LAYER_HEIGHT_EXCEEDS_LIMIT }; } // Validate extrusion widths. diff --git a/src/libslic3r/PrintBase.hpp b/src/libslic3r/PrintBase.hpp index 3f37205fb..07f1271c4 100644 --- a/src/libslic3r/PrintBase.hpp +++ b/src/libslic3r/PrintBase.hpp @@ -22,6 +22,7 @@ enum StringExceptionType { STRING_EXCEPT_FILAMENTS_DIFFERENT_TEMP = 2, STRING_EXCEPT_OBJECT_COLLISION_IN_SEQ_PRINT = 3, STRING_EXCEPT_OBJECT_COLLISION_IN_LAYER_PRINT = 4, + STRING_EXCEPT_LAYER_HEIGHT_EXCEEDS_LIMIT = 5, STRING_EXCEPT_COUNT }; diff --git a/src/libslic3r/Utils.hpp b/src/libslic3r/Utils.hpp index 655229a0e..66cd56d70 100644 --- a/src/libslic3r/Utils.hpp +++ b/src/libslic3r/Utils.hpp @@ -39,6 +39,7 @@ #define CLI_PRINTABLE_SIZE_REDUCED -20 #define CLI_OBJECT_ARRANGE_FAILED -21 #define CLI_OBJECT_ORIENT_FAILED -22 +#define CLI_MODIFIED_PARAMS_TO_PRINTER -23 #define CLI_NO_SUITABLE_OBJECTS -50