From 703b824526ff3d70cf30463174e59a8d7c5115b2 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 15 Sep 2021 17:09:54 +0200 Subject: [PATCH] MeshPart: show a more useful error message if the currently selected object cannot be tessellated --- src/Mod/MeshPart/Gui/Tessellation.cpp | 28 ++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/Mod/MeshPart/Gui/Tessellation.cpp b/src/Mod/MeshPart/Gui/Tessellation.cpp index aa343fc07b..2c01789194 100644 --- a/src/Mod/MeshPart/Gui/Tessellation.cpp +++ b/src/Mod/MeshPart/Gui/Tessellation.cpp @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include @@ -222,16 +222,38 @@ bool Tessellation::accept() this->document = QString::fromLatin1(activeDoc->getName()); + bool bodyWithNoTip = false; + bool partWithNoFace = false; for (auto &sel : Gui::Selection().getSelection("*",0)) { auto shape = Part::Feature::getTopoShape(sel.pObject,sel.SubName); if (shape.hasSubShape(TopAbs_FACE)) { shapeObjects.emplace_back(sel.pObject, sel.SubName); } + else if (sel.pObject) { + if (sel.pObject->isDerivedFrom(Part::Feature::getClassTypeId())) { + partWithNoFace = true; + } + if (sel.pObject->isDerivedFrom(Part::BodyBase::getClassTypeId())) { + Part::BodyBase* body = static_cast(sel.pObject); + if (!body->Tip.getValue()) { + bodyWithNoTip = true; + } + } + } } if (shapeObjects.empty()) { - QMessageBox::critical(this, windowTitle(), - tr("Select a shape for meshing, first.")); + if (bodyWithNoTip) { + QMessageBox::critical(this, windowTitle(), tr("You have selected a body without tip.\n" + "Either set the tip of the body or select a different shape, please.")); + } + else if (partWithNoFace) { + QMessageBox::critical(this, windowTitle(), tr("You have selected a shape without faces.\n" + "Select a different shape, please.")); + } + else { + QMessageBox::critical(this, windowTitle(), tr("Select a shape for meshing, first.")); + } return false; }