diff --git a/lib/Slic3r/GUI/PresetEditor.pm b/lib/Slic3r/GUI/PresetEditor.pm index 39f206134..c68753021 100644 --- a/lib/Slic3r/GUI/PresetEditor.pm +++ b/lib/Slic3r/GUI/PresetEditor.pm @@ -456,7 +456,7 @@ sub options { first_layer_acceleration default_acceleration skirts skirt_distance skirt_height min_skirt_length brim_connections_width brim_width interior_brim_width - support_material support_material_threshold support_material_enforce_layers + support_material support_material_threshold support_material_max_layers support_material_enforce_layers raft_layers support_material_pattern support_material_spacing support_material_angle support_material_interface_layers support_material_interface_spacing @@ -600,6 +600,7 @@ sub build { my $optgroup = $page->new_optgroup('Support material'); $optgroup->append_single_option_line('support_material'); $optgroup->append_single_option_line('support_material_threshold'); + $optgroup->append_single_option_line('support_material_max_layers'); $optgroup->append_single_option_line('support_material_enforce_layers'); } { @@ -926,6 +927,10 @@ sub _update { support_material_interface_layers dont_support_bridges support_material_extrusion_width support_material_interface_extrusion_width support_material_contact_distance); + + # Disable features that need support to be enabled. + $self->get_field($_)->toggle($config->support_material) + for qw(support_material_max_layers); $self->get_field($_)->toggle($have_support_material && $have_support_interface) for qw(support_material_interface_spacing support_material_interface_extruder diff --git a/lib/Slic3r/Print/SupportMaterial.pm b/lib/Slic3r/Print/SupportMaterial.pm index 202d010e1..7f080cbed 100644 --- a/lib/Slic3r/Print/SupportMaterial.pm +++ b/lib/Slic3r/Print/SupportMaterial.pm @@ -133,6 +133,8 @@ sub contact_area { last; } my $layer = $object->get_layer($layer_id); + last if $conf->support_material_max_layers + && $layer_id > $conf->support_material_max_layers; if ($buildplate_only) { # Collect the top surfaces up to this layer and merge them. diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index 142f5b0b3..aeb240792 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -1394,6 +1394,16 @@ PrintConfigDef::PrintConfigDef() def->enum_labels.push_back("0.2 (detachable)"); def->default_value = new ConfigOptionFloat(0.2); + def = this->add("support_material_max_layers", coInt); + def->label = "Max layer count for supports"; + def->category = "Support material"; + def->tooltip = "Disable support generation above this layer. Setting this to 0 will disable this feature."; + def->sidetext = "layers"; + def->cli = "support-material-max-layers=f"; + def->full_label = "Maximum layer count for support generation"; + def->min = 0; + def->default_value = new ConfigOptionInt(0); + def = this->add("support_material_enforce_layers", coInt); def->label = "Enforce support for the first"; def->category = "Support material"; diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp index 4b99924cb..0aa65ba28 100644 --- a/xs/src/libslic3r/PrintConfig.hpp +++ b/xs/src/libslic3r/PrintConfig.hpp @@ -171,6 +171,7 @@ class PrintObjectConfig : public virtual StaticPrintConfig ConfigOptionInt support_material_angle; ConfigOptionBool support_material_buildplate_only; ConfigOptionFloat support_material_contact_distance; + ConfigOptionInt support_material_max_layers; ConfigOptionInt support_material_enforce_layers; ConfigOptionInt support_material_extruder; ConfigOptionFloatOrPercent support_material_extrusion_width; @@ -208,6 +209,7 @@ class PrintObjectConfig : public virtual StaticPrintConfig OPT_PTR(support_material_angle); OPT_PTR(support_material_buildplate_only); OPT_PTR(support_material_contact_distance); + OPT_PTR(support_material_max_layers); OPT_PTR(support_material_enforce_layers); OPT_PTR(support_material_extruder); OPT_PTR(support_material_extrusion_width);