From 222300643a341d945f0c5e834b0ff96f924ac2d3 Mon Sep 17 00:00:00 2001 From: mpv Date: Thu, 19 Mar 2020 17:21:45 +0300 Subject: [PATCH 1/1] Fix for the issue #3167: Shaper study contains only result for feature having several results --- .../ConnectorPlugin_PublishToStudyFeature.py | 12 ++++++++++-- src/ModelHighAPI/ModelHighAPI_Dumper.cpp | 9 +++++++++ src/PythonAPI/model/services/__init__.py | 8 ++++++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py b/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py index 509b9a31b..a6a6d2d66 100644 --- a/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py +++ b/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py @@ -86,11 +86,19 @@ class PublishToStudyFeature(ModelAPI.ModelAPI_Feature): EventsAPI.Events_InfoMessage("PublishToStudy", "For publish to SHAPER-STUDY some Part is not activated", self).send() break aPartFeatureId = aPartSet.feature(aPartRes).data().featureId() + # Collects all features of exported results to find results of the same features and extend id. + # Map from feature index to index of result. If index is zero (initial), no surrfix to entry is added. + aFeaturesIndices = {} for aResId in range(aPartDoc.size(model.ModelAPI_ResultBody_group())): aResObject = aPartDoc.object(model.ModelAPI_ResultBody_group(), aResId) aRes = model.objectToResult(aResObject) - aResFeatureId = aPartDoc.feature(aRes).data().featureId() - aSSEntry = str(aPartFeatureId) + ":" + str(aResFeatureId) + aResFeatureId = str(aPartDoc.feature(aRes).data().featureId()) + if aResFeatureId in aFeaturesIndices: + aFeaturesIndices[aResFeatureId] += 1 + aResFeatureId += ":" + str(aFeaturesIndices[aResFeatureId]) + else: + aFeaturesIndices[aResFeatureId] = 0 + aSSEntry = str(aPartFeatureId) + ":" + aResFeatureId aSShape = anEngine.FindOrCreateShape(aSSEntry) aSShape.SetShapeByStream(aRes.shape().getShapeStream(False)) if not aSShape.GetSO(): # publish in case it is a new shape diff --git a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp index 7956062dd..10d5385ea 100644 --- a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp @@ -1606,6 +1606,15 @@ void ModelHighAPI_Dumper::exportVariables() const anEntryStr<second.myCurrentName); + size_t aSize = aFeature->results().size(); + if (aSize > 1) { // additional entries for features with more than one result + for(int a = 1; a < aSize; a++) { + std::ostringstream aResEntryStr; + aResEntryStr<second.myCurrentName); + } + } } } } diff --git a/src/PythonAPI/model/services/__init__.py b/src/PythonAPI/model/services/__init__.py index ce63d93a2..1548f4393 100644 --- a/src/PythonAPI/model/services/__init__.py +++ b/src/PythonAPI/model/services/__init__.py @@ -37,11 +37,15 @@ def publishToShaperStudy(): end() # returns unique identifier of the feature : id of part it belongs to + ":" + id of feature -def featureStringId(theFeature): +# the second argument may be the number of result if feature has more than one result (1 corresponds to the second result, etc) +def featureStringId(theFeature, *theArgs): aRoot = moduleDocument() aCurrent = theFeature.feature().document() if aRoot and aCurrent: - return str(findPartFeature(aRoot, aCurrent).data().featureId()) + ":" + str(theFeature.feature().data().featureId()) + aRes = str(findPartFeature(aRoot, aCurrent).data().featureId()) + ":" + str(theFeature.feature().data().featureId()) + if len(theArgs) == 1: + aRes += ":" + str(theArgs[0]) + return aRes return "" -- 2.39.2