diff --git a/src/Mod/TechDraw/Gui/CommandAnnotate.cpp b/src/Mod/TechDraw/Gui/CommandAnnotate.cpp index 0e9b173265..978ef62131 100644 --- a/src/Mod/TechDraw/Gui/CommandAnnotate.cpp +++ b/src/Mod/TechDraw/Gui/CommandAnnotate.cpp @@ -1424,29 +1424,32 @@ void CmdTechDrawDecorateLine::activated(int iMsg) } std::vector selection = getSelection().getSelectionEx(); - TechDraw::DrawViewPart* baseFeat = nullptr; if (selection.empty()) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong Selection"), QObject::tr("You must select a View and/or lines.")); return; } - baseFeat = dynamic_cast(selection[0].getObject()); + TechDraw::DrawViewPart* baseFeat = nullptr; + std::vector subNames; + + std::vector::iterator itSel = selection.begin(); + for (; itSel != selection.end(); itSel++) { + if ((*itSel).getObject()->isDerivedFrom()) { + subNames = (*itSel).getSubNames(); + if (!subNames.empty()) { + baseFeat = static_cast((*itSel).getObject()); + break; + } + } + } + if (!baseFeat) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong Selection"), QObject::tr("No View in Selection.")); return; } - std::vector subNames; - - std::vector::iterator itSel = selection.begin(); - for (; itSel != selection.end(); itSel++) { - if ((*itSel).getObject()->isDerivedFrom()) { - baseFeat = static_cast ((*itSel).getObject()); - subNames = (*itSel).getSubNames(); - } - } std::vector edgeNames; for (auto& s: subNames) { std::string geomType = DrawUtil::getGeomTypeFromName(s);