diff --git a/src/Mod/TechDraw/App/DrawViewPart.cpp b/src/Mod/TechDraw/App/DrawViewPart.cpp index d6c93534d8..9e39ce5af5 100644 --- a/src/Mod/TechDraw/App/DrawViewPart.cpp +++ b/src/Mod/TechDraw/App/DrawViewPart.cpp @@ -1130,7 +1130,13 @@ std::vector DrawViewPart::getSectionRefs() const std::vector inObjs = getInList(); for (auto& o : inObjs) { if (o->isDerivedFrom()) { - result.push_back(static_cast(o)); + // expressions can add extra links to this DVP so we keep only + // objects that are BaseViews + auto section = dynamic_cast(o); + auto base = section->BaseView.getValue(); + if (base == this) { + result.push_back(section); + } } } return result; @@ -1141,10 +1147,16 @@ std::vector DrawViewPart::getDetailRefs() const std::vector result; std::vector inObjs = getInList(); for (auto& o : inObjs) { - if (o->isDerivedFrom()) { - if (!o->isRemoving()) { - result.push_back(static_cast(o)); + if (o->isDerivedFrom() && + !o->isRemoving() ) { + // expressions can add extra links to this DVP so we keep only + // objects that are BaseViews + auto detail = dynamic_cast(o); + auto base = detail->BaseView.getValue(); + if (base == this) { + result.push_back(detail); } + } } return result;