diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index c3fbb7b34..0d5830614 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -322,6 +322,13 @@ sub export_gcode { $status_cb->(10, "Processing triangulated mesh"); $_->slice for @{$self->objects}; + # remove empty layers and abort if there are no more + # as some algorithms assume all objects have at least one layer + # note: this will change object indexes + @{$self->objects} = grep @{$_->layers}, @{$self->objects}; + die "No layers were detected. You might want to repair your STL file(s) or check their size and retry.\n" + if !@{$self->objects}; + if ($Slic3r::Config->resolution) { $status_cb->(15, "Simplifying input"); $self->_simplify_slices(scale $Slic3r::Config->resolution); diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index 6e8067382..dc5428dc9 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -190,7 +190,6 @@ sub slice { # remove last layer(s) if empty pop @{$self->layers} while @{$self->layers} && (!map @{$_->lines}, @{$self->layers->[-1]->regions}); - die "Invalid or too thin input file: no layers could be generated\n" if !@{$self->layers}; foreach my $layer (@{ $self->layers }) { # make sure all layers contain layer region objects for all regions @@ -277,9 +276,6 @@ sub slice { $self->layers->[$i]->id($i); } } - - warn "No layers were detected. You might want to repair your STL file and retry.\n" - if !@{$self->layers}; } sub make_perimeters {