From 39b6a1e3a843d83fb96dd0ce421373cbad7b4584 Mon Sep 17 00:00:00 2001 From: PaddleStroke Date: Mon, 19 May 2025 09:36:47 +0200 Subject: [PATCH] TechDraw: decorateLine fix (#21312) * TechDraw: decorateLine fix * Update CommandAnnotate.cpp --- src/Mod/TechDraw/Gui/CommandAnnotate.cpp | 25 +++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) 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);