diff --git a/localization/i18n/OrcaSlicer.pot b/localization/i18n/OrcaSlicer.pot index c679c1829f..b221f073b7 100644 --- a/localization/i18n/OrcaSlicer.pot +++ b/localization/i18n/OrcaSlicer.pot @@ -5320,6 +5320,9 @@ msgstr "" msgid "This parameter expects a valid template." msgstr "" +msgid "Invalid collision volume format. Use XxY, XxY, ... or ZMIN..ZMAX;XxY, XxY, ... and separate multiple volumes with |." +msgstr "" + msgid "Invalid pattern. Use N, N#K, or a comma-separated list with optional #K per entry. Examples: 5, 5#2, 1,7,9, 5,9#2,18." msgstr "" @@ -6518,6 +6521,12 @@ msgstr "" msgid "Show object labels in 3D scene." msgstr "" +msgid "Show all collision volumes" +msgstr "" + +msgid "Show the full height of every configured collision volume, including on an empty bed." +msgstr "" + msgid "Show &Overhang" msgstr "" @@ -11046,6 +11055,12 @@ msgstr "" msgid "Click to reset all settings to the last saved preset." msgstr "" +msgid "This definition contains collision-volume syntax. Add it to the toolhead collision volumes for G-code checking and travel avoidance? The existing excluded bed area will be preserved." +msgstr "" + +msgid "Add collision volumes" +msgstr "" + msgid "Prime tower is required for nozzle changing. There may be flaws on the model without prime tower. Are you sure you want to disable prime tower?" msgstr "" @@ -12708,6 +12723,17 @@ msgid "" "Is the disk full?" msgstr "" +#, possible-boost-format +msgid "A G-code move intersects a collision volume for extruder %1%. This may cause a printer collision." +msgstr "" + +msgid "A G-code move intersects a collision volume. This may cause a printer collision." +msgstr "" + +#, possible-boost-format +msgid "The intersecting move is at G-code line %1%. Its Z position is unknown after homing, so Orca checked it against every height." +msgstr "" + #. TRN %1% is the temporary file path, %2% the output file path, %3% the system error message. #, possible-boost-format msgid "" @@ -12974,6 +13000,14 @@ msgstr "" msgid "%1% is too close to exclusion area. There may be collisions when printing." msgstr "" +#, possible-boost-format +msgid "%1% intersects collision volumes for every available extruder." +msgstr "" + +#, possible-boost-format +msgid "%1% intersects a collision volume for extruder %2%." +msgstr "" + #, possible-boost-format msgid "%1% is too close to others, and collisions may be caused." msgstr "" @@ -13303,7 +13337,34 @@ msgstr "" msgid "Excluded bed area" msgstr "" -msgid "Unprintable area in XY plane. For example, X1 Series printers use the front left corner to cut filament during filament change. The area is expressed as polygon by points in following format: \"XxY, XxY, ...\"" +msgid "Unprintable area in XY plane. For example, X1 Series printers use the front left corner to cut filament during filament change. The area is expressed as a polygon in the format \"XxY, XxY, ...\". It constrains material and model placement, but allows machine travel. Configure toolhead collision volumes separately for G-code checking and travel avoidance." +msgstr "" + +msgid "Toolhead collision volumes" +msgstr "" + +msgid "Collision volumes used for model and generated-material exclusion, G-code checking, and travel avoidance. Use \"XxY, XxY, ...\" for a full-height polygon or \"ZMIN..ZMAX;XxY, XxY, ...\" for a Z-limited volume. Separate multiple volumes with \"|\". These volumes are additional to the excluded bed area. Automatic arrangement conservatively uses the bounding box of a non-convex volume." +msgstr "" + +msgid "Collision volume behavior" +msgstr "" + +msgid "Choose whether all nozzles use the same collision volumes, derive toolhead-relative volumes from each nozzle's XY offset, or configure independent volumes for every extruder. In individual mode, select each extruder on the Extruder page to configure its volumes." +msgstr "" + +msgid "Shared" +msgstr "" + +msgid "Toolhead-relative (nozzle offsets)" +msgstr "" + +msgid "Individual per extruder" +msgstr "" + +msgid "Extruder collision volumes" +msgstr "" + +msgid "Collision volumes used only by this extruder in individual mode. Use the same polygon and optional Z-range format as the shared collision volumes. Leave empty for no collision volumes on this extruder. Automatic arrangement conservatively uses the bounding box of a non-convex volume." msgstr "" msgid "Bed custom texture" @@ -18210,6 +18271,15 @@ msgstr "" msgid "invalid value " msgstr "" +msgid "Invalid collision volume definition." +msgstr "" + +msgid "A nozzle offset is required for every extruder when toolhead-relative collision volumes are enabled." +msgstr "" + +msgid "Invalid per-extruder collision volume definition." +msgstr "" + msgid "Invalid value when spiral vase mode is enabled: " msgstr "" diff --git a/src/OrcaSlicer.cpp b/src/OrcaSlicer.cpp index 8baf6dc114..9eff0ceb46 100644 --- a/src/OrcaSlicer.cpp +++ b/src/OrcaSlicer.cpp @@ -187,7 +187,7 @@ using namespace Slic3r; static Pointfs legacy_bed_exclude_area_points(const DynamicPrintConfig &config) { const ConfigOptionPoints *option = config.option("bed_exclude_area"); - return option != nullptr && !has_bed_exclude_volumes(config) ? option->values : Pointfs{}; + return option != nullptr ? option->values : Pointfs{}; } std::map cli_errors = { diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index b10224aa97..8e3efd3289 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -338,7 +338,7 @@ static std::vector get_path_of_change_filament(const Print& print) Vec2d end_point = points[1]; // the cutter area size(18, 28) - Pointfs excluse_area = has_bed_exclude_volumes(print.config()) ? Pointfs{} : print.config().bed_exclude_area.values; + Pointfs excluse_area = print.config().bed_exclude_area.values; if (excluse_area.size() != 4) return out_points; @@ -2992,9 +2992,9 @@ void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* resu const int extruder_id = m_processor.get_result().exclusion_volume_conflict_extruder_id; std::string warning = extruder_id >= 0 ? Slic3r::format( - _(L("A G-code move intersects an exclusion volume for extruder %1%. This may cause a printer collision.")), + _(L("A G-code move intersects a collision volume for extruder %1%. This may cause a printer collision.")), std::to_string(extruder_id + 1)) : - _(L("A G-code move intersects an exclusion volume. This may cause a printer collision.")); + _(L("A G-code move intersects a collision volume. This may cause a printer collision.")); if (m_processor.get_result().exclusion_volume_conflict_used_unknown_z) { warning += "\n" + Slic3r::format( _(L("The intersecting move is at G-code line %1%. Its Z position is unknown after homing, so Orca checked it against every height.")), diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp index 932e049691..39b0b13b05 100644 --- a/src/libslic3r/GCode/GCodeProcessor.cpp +++ b/src/libslic3r/GCode/GCodeProcessor.cpp @@ -3328,7 +3328,7 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config) //BBS: add bed_exclude_area const ConfigOptionPoints* bed_exclude_area = config.option("bed_exclude_area"); - if (bed_exclude_area != nullptr && !has_bed_exclude_volumes(config)) + if (bed_exclude_area != nullptr) m_result.bed_exclude_area = bed_exclude_area->values; const ConfigOptionPoints* wrapping_exclude_area = config.option("wrapping_exclude_area"); diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index 26d5ea368f..ed1ce9379d 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -949,8 +949,8 @@ StringObjectException Print::sequential_print_clearance_valid(const Print &print const std::string collision_message = !exclusion_collision->collision_volume ? (boost::format(L("%1% is too close to exclusion area. There may be collisions when printing.")) % instance.model_instance->get_object()->name).str() : is_auto_filament_map_mode(print.get_filament_map_mode()) && print.is_BBL_printer() ? - (boost::format(L("%1% intersects exclusion volumes for every available extruder.")) % instance.model_instance->get_object()->name).str() : - (boost::format(L("%1% intersects an exclusion volume for extruder %2%.")) % instance.model_instance->get_object()->name % (exclusion_collision->extruder_id + 1)).str(); + (boost::format(L("%1% intersects collision volumes for every available extruder.")) % instance.model_instance->get_object()->name).str() : + (boost::format(L("%1% intersects a collision volume for extruder %2%.")) % instance.model_instance->get_object()->name % (exclusion_collision->extruder_id + 1)).str(); if (single_object_exception.string.empty()) { single_object_exception.string = collision_message; // single_object_exception.object = instance.model_instance->get_object(); @@ -1620,8 +1620,8 @@ static StringObjectException layered_print_cleareance_valid(const Print &print, const std::string message = !exclusion_collision->collision_volume ? (boost::format(L("%1% is too close to exclusion area. There may be collisions when printing.")) % inst->model_instance->get_object()->name).str() : is_auto_filament_map_mode(print.get_filament_map_mode()) && print.is_BBL_printer() ? - (boost::format(L("%1% intersects exclusion volumes for every available extruder.")) % inst->model_instance->get_object()->name).str() : - (boost::format(L("%1% intersects an exclusion volume for extruder %2%.")) % inst->model_instance->get_object()->name % (exclusion_collision->extruder_id + 1)).str(); + (boost::format(L("%1% intersects collision volumes for every available extruder.")) % inst->model_instance->get_object()->name).str() : + (boost::format(L("%1% intersects a collision volume for extruder %2%.")) % inst->model_instance->get_object()->name % (exclusion_collision->extruder_id + 1)).str(); return {message + "\n", inst->model_instance}; } diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index b75b0a82fa..01e3184efd 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -1057,8 +1057,8 @@ void PrintConfigDef::init_common_params() def->set_default_value(new ConfigOptionString()); def = this->add("bed_exclude_volume_mode", coEnum); - def->label = L("Collision volume behaviour"); - def->tooltip = L("Choose whether all nozzles use the same exclusion volumes, derive toolhead-relative volumes from each nozzle's XY offset, or configure independent volumes for every extruder. In individual mode, select each extruder on the Extruder page to configure its volumes."); + def->label = L("Collision volume behavior"); + def->tooltip = L("Choose whether all nozzles use the same collision volumes, derive toolhead-relative volumes from each nozzle's XY offset, or configure independent volumes for every extruder. In individual mode, select each extruder on the Extruder page to configure its volumes."); def->enum_keys_map = &ConfigOptionEnum::get_enum_values(); def->enum_values = { "shared", "toolhead_offset", "per_extruder" }; def->enum_labels = { L("Shared"), L("Toolhead-relative (nozzle offsets)"), L("Individual per extruder") }; @@ -1067,7 +1067,7 @@ void PrintConfigDef::init_common_params() def = this->add("extruder_bed_exclude_volumes", coStrings); def->label = L("Extruder collision volumes"); - def->tooltip = L("Collision volumes used only by this extruder in individual mode. Use the same polygon and optional Z-range format as the shared exclusion volumes. Leave empty for no exclusion volumes on this extruder. Automatic arrangement conservatively uses the bounding box of a non-convex volume."); + def->tooltip = L("Collision volumes used only by this extruder in individual mode. Use the same polygon and optional Z-range format as the shared collision volumes. Leave empty for no collision volumes on this extruder. Automatic arrangement conservatively uses the bounding box of a non-convex volume."); def->mode = comAdvanced; def->gui_type = ConfigOptionDef::GUIType::one_string; def->set_default_value(new ConfigOptionStrings{ "" }); @@ -12394,16 +12394,16 @@ std::map validate(const FullPrintConfig &cfg, bool und if (cfg.bed_exclude_volume_mode.value != BedExcludeVolumeMode::PerExtruder && !cfg.bed_exclude_volumes.value.empty() && !is_valid_bed_exclude_volumes_string(cfg.bed_exclude_volumes.value, cfg.printable_height.value)) { - error_message.emplace("bed_exclude_volumes", L("Invalid exclusion volume definition.")); + error_message.emplace("bed_exclude_volumes", L("Invalid collision volume definition.")); } if (collision_volumes_enabled && cfg.bed_exclude_volume_mode.value == BedExcludeVolumeMode::ToolheadOffset && cfg.extruder_offset.size() < cfg.nozzle_diameter.size()) { - error_message.emplace("extruder_offset", L("A nozzle offset is required for every extruder when toolhead-relative exclusion volumes are enabled.")); + error_message.emplace("extruder_offset", L("A nozzle offset is required for every extruder when toolhead-relative collision volumes are enabled.")); } if (collision_volumes_enabled && cfg.bed_exclude_volume_mode.value == BedExcludeVolumeMode::PerExtruder) { for (const std::string &entry : cfg.extruder_bed_exclude_volumes.values) { if (!is_valid_bed_exclude_volumes_string(entry, cfg.printable_height.value)) { - error_message.emplace("extruder_bed_exclude_volumes", L("Invalid per-extruder exclusion volume definition.")); + error_message.emplace("extruder_bed_exclude_volumes", L("Invalid per-extruder collision volume definition.")); break; } } diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index 54ec91f672..55c491f811 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -736,7 +736,7 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true } else if (m_opt.opt_key == "bed_exclude_volumes" || m_opt.opt_key == "extruder_bed_exclude_volumes") { const std::string definition = into_u8(str); if (!is_valid_bed_exclude_volumes_string(definition, std::numeric_limits::max())) { - show_error(m_parent, _L("Invalid exclusion volume format. Use XxY, XxY, ... or ZMIN..ZMAX;XxY, XxY, ... and separate multiple volumes with |.")); + show_error(m_parent, _L("Invalid collision volume format. Use XxY, XxY, ... or ZMIN..ZMAX;XxY, XxY, ... and separate multiple volumes with |.")); const std::string old_value = m_value.empty() ? std::string{} : boost::any_cast(m_value); set_value(from_u8(old_value), true); break; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 469afeb3b3..e639ab8b00 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -21678,7 +21678,7 @@ void Plater::set_bed_shape() const const ConfigOptionPoints *bed_exclude_area = p->config->option("bed_exclude_area"); set_bed_shape(p->config->option("printable_area")->values, //BBS: add bed exclude areas - has_bed_exclude_volumes(*p->config) ? Pointfs{} : bed_exclude_area->values, + bed_exclude_area->values, p->config->option("wrapping_exclude_area")->values, p->config->option("printable_height")->value, p->config->option("extruder_printable_area")->values, diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 1e6bc8b97c..07b857d443 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1952,7 +1952,7 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value) if (definition != nullptr && is_bed_exclusion_volume_syntax(*definition)) { const double printable_height = m_config->opt_float("printable_height"); if (!is_valid_bed_exclude_volumes_string(*definition, printable_height)) { - show_error(wxGetApp().plater(), _L("Invalid exclusion volume format. Use XxY, XxY, ... or ZMIN..ZMAX;XxY, XxY, ... and separate multiple volumes with |.")); + show_error(wxGetApp().plater(), _L("Invalid collision volume format. Use XxY, XxY, ... or ZMIN..ZMAX;XxY, XxY, ... and separate multiple volumes with |.")); reload_config(); return; } @@ -5302,8 +5302,8 @@ void TabPrinter::build_fff() option = optgroup->get_option("bed_exclude_volumes"); option.opt.full_width = true; - optgroup->append_single_option_line(option); - optgroup->append_single_option_line("bed_exclude_volume_mode"); + optgroup->append_single_option_line(option, "printer_basic_information_printable_space#toolhead-collision-volumes"); + optgroup->append_single_option_line("bed_exclude_volume_mode", "printer_basic_information_printable_space#toolhead-collision-volumes"); optgroup->append_single_option_line("printable_height", "printer_basic_information_printable_space#printable-height"); optgroup->append_single_option_line("support_multi_bed_types", "printer_basic_information_printable_space#support-multi-bed-types"); @@ -6123,7 +6123,7 @@ if (is_marlin_flavor) Option exclusion_option = optgroup->get_option("extruder_bed_exclude_volumes", extruder_idx); exclusion_option.opt.full_width = true; - optgroup->append_single_option_line(exclusion_option, "printer_basic_information_printable_space#excluded-bed-area"); + optgroup->append_single_option_line(exclusion_option, "printer_basic_information_printable_space#toolhead-collision-volumes"); optgroup->m_on_change = [this](const t_config_option_key& opt_key, boost::any value) { diff --git a/tests/fff_print/test_exclusion_volumes.cpp b/tests/fff_print/test_exclusion_volumes.cpp index 1393c5e01a..6b20d07973 100644 --- a/tests/fff_print/test_exclusion_volumes.cpp +++ b/tests/fff_print/test_exclusion_volumes.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include "libslic3r/Config.hpp" #include "libslic3r/ExPolygon.hpp" #include "libslic3r/Model.hpp" @@ -377,6 +378,65 @@ TEST_CASE("Legacy excluded areas do not constrain machine motion", "[ExclusionVo CHECK(route.path.points == direct.points); } +TEST_CASE("G-code preview retains the bed area alongside collision volumes", "[ExclusionVolume][GCode][Compatibility][Regression]") +{ + const auto mode = GENERATE(BedExcludeVolumeMode::Shared, BedExcludeVolumeMode::ToolheadOffset, + BedExcludeVolumeMode::PerExtruder); + DynamicPrintConfig config = exclusion_config(mode, "0..10;70x70,80x70,80x80,70x80", + {"0..10;70x70,80x70,80x80,70x80"}); + config.set_deserialize_strict("bed_exclude_area", "0x0,18x0,18x28,0x28"); + ScopedTemporaryFile file(".gcode"); + { + std::ofstream output(file.string()); + REQUIRE(output.is_open()); + output << "; generated by OrcaSlicer\nG90\nM83\nG1 X30 Y30 Z0.2 F3000\n" + << "; CONFIG_BLOCK_START\n"; + for (const std::string &key : config.keys()) + output << "; " << key << " = " << config.opt_serialize(key) << '\n'; + output << "; CONFIG_BLOCK_END\n"; + REQUIRE(output.good()); + } + ScopedBblPrinterMode printer_mode(false); + GCodeProcessor processor; + // Standalone preview loading uses the embedded DynamicPrintConfig, not + // the streaming writer's PrintConfig overload. + processor.process_file(file.string()); + CHECK(processor.get_result().bed_exclude_area == config.option("bed_exclude_area")->values); +} + +TEST_CASE("Collision volumes preserve the configured cutter travel points", "[ExclusionVolume][GCode][Compatibility][Regression]") +{ + DynamicPrintConfig config = Test::multifilament_config(2, { + {"enable_prime_tower", "0"}, {"gcode_flavor", "klipper"}, + {"start_end_points", "20x-3,60x90"}, {"bed_exclude_area", "0x0,18x0,18x28,0x28"}, + {"change_filament_gcode", ";CUTTER_PATH [travel_point_1_x],[travel_point_1_y];[travel_point_2_x],[travel_point_2_y];[travel_point_3_x],[travel_point_3_y]"}, + }); + const auto cutter_path = [](const DynamicPrintConfig &settings) { + Model model; + Print print; + const std::vector> overrides{ + {{"extruder", "1"}}, {{"extruder", "2"}}}; + std::vector meshes; + for (const double x : {30.0, 45.0}) { + TriangleMesh mesh = make_cube(5.0, 5.0, 0.6); + mesh.translate(Vec3f(float(x), 40.0f, 0.0f)); + meshes.push_back(std::move(mesh)); + } + Test::init_print(std::move(meshes), print, model, settings, &overrides, false); + const std::string gcode = Test::gcode(print); + const size_t marker = gcode.find(";CUTTER_PATH "); + REQUIRE(marker != std::string::npos); + return gcode.substr(marker, gcode.find('\n', marker) - marker); + }; + const std::string expected = cutter_path(config); + // The configured endpoint differs from the fallback (54, 245), so this + // comparison cannot pass by silently disabling the cutter-area calculation. + CHECK_THAT(expected, Catch::Matchers::ContainsSubstring("60")); + CHECK_THAT(expected, Catch::Matchers::ContainsSubstring("90")); + config.set_key_value("bed_exclude_volumes", new ConfigOptionString("0..10;80x80,90x80,90x90,80x90")); + CHECK(cutter_path(config) == expected); +} + TEST_CASE("Path checker detects crossing inside and boundary motions", "[ExclusionVolume][GCode]") { const FullPrintConfig config = static_config(exclusion_config());