Skip to content

Commit

Permalink
Empty layers check converted to a warning (except for the first layer)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmatena committed Jul 16, 2020
1 parent ba01467 commit f326352
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/libslic3r/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,13 @@ std::vector<GCode::LayerToPrint> GCode::collect_layers_to_print(const PrintObjec

layers_to_print.emplace_back(layer_to_print);

// Check that there are extrusions on the very first layer.
if (layers_to_print.size() == 1u) {
if ((layer_to_print.object_layer && ! layer_to_print.object_layer->has_extrusions())
|| (layer_to_print.support_layer && ! layer_to_print.support_layer->has_extrusions()))
throw std::runtime_error(_(L("There is an object with no extrusions on the first layer.")));
}

// In case there are extrusions on this layer, check there is a layer to lay it on.
if ((layer_to_print.object_layer && layer_to_print.object_layer->has_extrusions())
// Allow empty support layers, as the support generator may produce no extrusions for non-empty support regions.
Expand All @@ -634,14 +641,18 @@ std::vector<GCode::LayerToPrint> GCode::collect_layers_to_print(const PrintObjec
bool has_extrusions = (layer_to_print.object_layer && layer_to_print.object_layer->has_extrusions())
|| (layer_to_print.support_layer && layer_to_print.support_layer->has_extrusions());

if (has_extrusions && layer_to_print.print_z() > maximal_print_z + 2. * EPSILON)
throw std::runtime_error(_(L("Empty layers detected, the output would not be printable.")) + "\n\n" +
if (has_extrusions && layer_to_print.print_z() > maximal_print_z + 2. * EPSILON) {
const_cast<Print*>(object.print())->active_step_add_warning(PrintStateBase::WarningLevel::CRITICAL,
_(L("Empty layers detected, the output would not be printable.")) + "\n\n" +
_(L("Object name")) + ": " + object.model_object()->name + "\n" + _(L("Print z")) + ": " +
std::to_string(layers_to_print.back().print_z()) + "\n\n" + _(L("This is "
"usually caused by negligibly small extrusions or by a faulty model. Try to repair "
"the model or change its orientation on the bed.")));
}

// Remember last layer with extrusions.
last_extrusion_layer = &layers_to_print.back();
if (has_extrusions)
last_extrusion_layer = &layers_to_print.back();
}
}

Expand Down Expand Up @@ -1939,7 +1950,6 @@ void GCode::process_layer(
const size_t single_object_instance_idx)
{
assert(! layers.empty());
// assert(! layer_tools.extruders.empty());
// Either printing all copies of all objects, or just a single copy of a single object.
assert(single_object_instance_idx == size_t(-1) || layers.size() == 1);

Expand Down

6 comments on commit f326352

@n8bot
Copy link
Contributor

@n8bot n8bot commented on f326352 Jul 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just built the latest version today and tested it. This empty layer error does not account for support extrusion on the first layer.

Previously, if there were support structures on the first layer, there was no error. Now, I can not export the gcode.

The reason the object I am printing does not produce extrusion on the first layer is because of the settings/orientation. See:
partorientation

Maybe the best way to fix this would be to force the object to be lower in layer height increments until extrusion is produced.

@lukasmatena
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@n8bot You are right. The test gives false positive when first layer is both object and support layer. Hopefully fixed with d910f79. Can you retest it, please?
Thank you very much for letting us know.

@n8bot
Copy link
Contributor

@n8bot n8bot commented on f326352 Jul 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, that wasn't exactly what I had noticed but I'm glad you found that. The orientation/settings I use for this model never generate any object extrusion on the first layer. I was merely noticing the error being triggered when only extrusion/skirt was on the first layer, with no object extrusion.

Regardless, I'll build and test the new changes tomorrow! Thank YOU for the continued work on PS.

@n8bot
Copy link
Contributor

@n8bot n8bot commented on f326352 Jul 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I built PS including your change, as well as this recent change (not sure if it is directly related) f7ceffb

It seems to work fine, as it did before! Now, I can slice the model, and while there is no object extrusion on the first layer, the presence of support extrusion on the first layer correctly suppresses the error. Also, when I disable support generation, the error correctly comes up because there is truly no extrusion (except skirt) on the first layer.

So, the error check seems fixed! I may open an issue about model not generating first layer extrusion -- a possible fix could be if the model generates no extrusion on the first layer, just because the surface area is literally infinitesimal, then the model could be lowered in Z until a suitable first layer is produced (perhaps, with a user setting for mm^2 of surface area required for first layer).

Cheers!

@lukasmatena
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was merely noticing the error being triggered when only extrusion/skirt was on the first layer, with no object extrusion.

Yes, that was the problem. The condition above throws error in case that object_layer==true and there are no object extrusions. But in case that also support_layer==true and it has support extrusions, it is fine. The second bit was not covered correctly by the compound condition.

then the model could be lowered in Z until a suitable first layer is produced

Yes, we also discussed this, but implementing it would require more work and testing that all corner cases (rafts, supports, wipe tower, spiral vase mode, custom gcodes, modifier meshes,...) are handled correctly. Maybe one day.

So, the error check seems fixed!

Glad to hear that. What is missing is actually reporting the warning if it is triggered, but that is coming soon.
Thanks for keeping an eye on us.

@n8bot
Copy link
Contributor

@n8bot n8bot commented on f326352 Jul 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. A final thought is that maybe simply allowing the user to manually force the model Z position below the calculated minimum would work. A warning that this may produce extrusion below z=0 would be sensible alongside that. Just a thought!

Please sign in to comment.