From b92b4388de3b92c38f3065b76f0314c3aa0ed39f Mon Sep 17 00:00:00 2001 From: mpv Date: Wed, 11 Dec 2019 14:38:22 +0300 Subject: [PATCH] Correct creation of shapes in SHAPER-STUDY --- .../ConnectorPlugin_PublishToStudyFeature.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py b/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py index 725939b7b..45ec3985f 100644 --- a/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py +++ b/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py @@ -61,10 +61,22 @@ class PublishToStudyFeature(ModelAPI.ModelAPI_Feature): def execute(self): print("### Execution of PublishToStudy") - ## Get SHAPER active document - aSession = ModelAPI.ModelAPI_Session.get() # find a shaper-study component salome.salome_init(1) import SHAPERSTUDY_utils SHAPERSTUDY_utils.findOrCreateComponent() anEngine = SHAPERSTUDY_utils.getEngine() + + # iterate all parts and all results to publish them in SHAPER_STUDY + aSession = ModelAPI.ModelAPI_Session.get() + aPartSet = aSession.moduleDocument() + for aPartId in range(aPartSet.size(model.ModelAPI_ResultPart_group())): + aPartObject = aPartSet.object(model.ModelAPI_ResultPart_group(), aPartId) + aPart = ModelAPI.modelAPI_ResultPart(ModelAPI.modelAPI_Result(aPartObject)).partDoc() + for aResId in range(aPart.size(model.ModelAPI_ResultBody_group())): + aResObject = aPart.object(model.ModelAPI_ResultBody_group(), aResId) + aRes = model.objectToResult(aResObject) + print("Found a result to publish ", aRes.data().name()) + aSShape = anEngine.CreateShape() + aSShape.SetShapeByStream(aRes.shape().getShapeStream()) + anEngine.AddInStudy(aSShape, aRes.data().name(), None) -- 2.39.2