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
anEntryStr<<aPartId<<":"<<aFeatureId;
std::string anEntry = anEntryStr.str();
exportVariable(anEntry, aNameIter->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<<anEntry<<":"<<a;
+ std::string aResEntry = aResEntryStr.str();
+ exportVariable(aResEntry, aNameIter->second.myCurrentName);
+ }
+ }
}
}
}
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 ""