From cd8f50ce5c9cf41e43a1f9b7155d12aad1c37494 Mon Sep 17 00:00:00 2001 From: dbv Date: Mon, 5 Sep 2016 13:09:39 +0300 Subject: [PATCH] Fix for selection by name with suffix --- src/Model/Model_SelectionNaming.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Model/Model_SelectionNaming.cpp b/src/Model/Model_SelectionNaming.cpp index f85886a01..ecf334303 100644 --- a/src/Model/Model_SelectionNaming.cpp +++ b/src/Model/Model_SelectionNaming.cpp @@ -335,15 +335,18 @@ const TopoDS_Shape getShapeFromNS( { TopoDS_Shape aSelection; std::string::size_type n = theSubShapeName.rfind('/'); - if (n == std::string::npos) n = 0; + if (n == std::string::npos) n = -1; std::string aSubString = theSubShapeName.substr(n + 1); n = aSubString.rfind('_'); - int indx; - if (n == std::string::npos) {// for primitives this is a first - indx = 1; - } else { - aSubString = aSubString.substr(n+1); - indx = atoi(aSubString.c_str()); + int indx = 1; + if (n != std::string::npos) {// for primitives this is a first + // if we have here the same name as theSubShapeName, there is no index in compound, it is whole + Handle(TDataStd_Name) aName; + if (!theNS->Label().FindAttribute(TDataStd_Name::GetID(), aName) || + aName->Get() != theSubShapeName.c_str()) { + aSubString = aSubString.substr(n+1); + indx = atoi(aSubString.c_str()); + } } TNaming_Iterator anItL(theNS); -- 2.39.2