diff --git a/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp b/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp index 6c007b8761..13ccbea6cd 100644 --- a/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp +++ b/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp @@ -375,7 +375,7 @@ void CmdSketcherSelectConstraints::activated(int iMsg) // get the needed lists and objects const std::vector& SubNames = selection[0].getSubNames(); Sketcher::SketchObject* Obj = static_cast(selection[0].getObject()); - const std::vector& vals = Obj->Constraints.getValues(); + const std::vector& constraints = Obj->Constraints.getValues(); std::string doc_name = Obj->getDocument()->getName(); std::string obj_name = Obj->getNameInDocument(); @@ -384,23 +384,26 @@ void CmdSketcherSelectConstraints::activated(int iMsg) std::vector constraintSubNames; // go through the selected subelements - for (std::vector::const_iterator it = SubNames.begin(); it != SubNames.end(); - ++it) { - // only handle edges - if (it->size() > 4 && it->substr(0, 4) == "Edge") { - int GeoId = std::atoi(it->substr(4, 4000).c_str()) - 1; - - // push all the constraints - int i = 0; - for (std::vector::const_iterator it = vals.begin(); - it != vals.end(); - ++it, ++i) { - if ((*it)->First == GeoId || (*it)->Second == GeoId || (*it)->Third == GeoId) { - constraintSubNames.push_back( - Sketcher::PropertyConstraintList::getConstraintName(i)); - } + int i = 0; + for (auto const& constraint : constraints) { + auto isRelated = [&] (const std::string& subName){ + int geoId; + PointPos pointPos; + Data::IndexedName name = Obj->checkSubName(subName.c_str()); + if (!Obj->geoIdFromShapeType(name, geoId, pointPos)) { + return false; } + if (pointPos != PointPos::none) { + return constraint->involvesGeoIdAndPosId(geoId, pointPos); + } else { + return constraint->involvesGeoId(geoId); + } + }; + + if (std::ranges::any_of(SubNames, isRelated)) { + constraintSubNames.push_back(PropertyConstraintList::getConstraintName(i)); } + ++i; } if (!constraintSubNames.empty())