From 0556a4e6e3025c121fa844a7dda2792a4e5645d8 Mon Sep 17 00:00:00 2001 From: mpv Date: Fri, 5 Jun 2020 16:08:13 +0300 Subject: [PATCH] Fix for the issue #19231: Wrong group in SHAPERSTUDY created by GroupSubstraction --- .../ConnectorPlugin_PublishToStudyFeature.py | 28 ++++++------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py b/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py index 6e3629fbf..30be5591d 100644 --- a/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py +++ b/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py @@ -173,25 +173,15 @@ class PublishToStudyFeature(ModelAPI.ModelAPI_Feature): else: aSelList = aRef.selectionList("group_list") aSelType = GeomAPI_Shape.shapeTypeByStr(aSelList.selectionType()) - for aSelIndex in range(aSelList.size()): - aSelection = aSelList.value(aSelIndex) - if aSelection.contextObject(): - aShape = aSelection.value() - if aShape: - allShapesList = [] # collect all sub-shapes selected in the group - if aShape.shapeType() == 0 or aShape.shapeType() != aSelType: # compound or whole res - anExplorer = GeomAPI_ShapeExplorer(aShape, aSelType) - while anExplorer.more(): - allShapesList.append(anExplorer.current()) - anExplorer.next() - else: - allShapesList.append(aShape) - # get index of each selected shape: if 0, this sub-shape is not in our result - for aSelected in allShapesList: - anId = GeomAlgoAPI.GeomAlgoAPI_CompoundBuilder.id(aResShape, aSelected) - if anId > 0 and not anId in aGroupHasIndex: - aGroupIndices.append(anId) - aGroupHasIndex[anId] = 0 + for aGroupRes in aRef.results(): + aShape = aGroupRes.shape() + anExplorer = GeomAPI_ShapeExplorer(aShape, aSelType) + while anExplorer.more(): + anId = GeomAlgoAPI.GeomAlgoAPI_CompoundBuilder.id(aResShape, anExplorer.current()) + if anId > 0 and not anId in aGroupHasIndex: + aGroupIndices.append(anId) + aGroupHasIndex[anId] = 0 + anExplorer.next() if len(aGroupIndices): # create group aGroupFeatureId = aRef.data().featureId() if theFields: -- 2.39.2