X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FConnectorPlugin%2FConnectorPlugin_ExportFeature.py;h=9241308435320ab15b5bc4f3b83fd8f7431371cb;hb=857b1f72d9703c46c6c8c9bb239821d314344c86;hp=e69b259fe73e248ffcc950f15fd775f2cc918af8;hpb=e18f820916dd4c72fd64ae6d0c36fd7a934867d5;p=modules%2Fshaper.git diff --git a/src/ConnectorPlugin/ConnectorPlugin_ExportFeature.py b/src/ConnectorPlugin/ConnectorPlugin_ExportFeature.py index e69b259fe..924130843 100644 --- a/src/ConnectorPlugin/ConnectorPlugin_ExportFeature.py +++ b/src/ConnectorPlugin/ConnectorPlugin_ExportFeature.py @@ -8,6 +8,15 @@ import ModelAPI import salome from salome.geom import geomBuilder +def getObjectIndex(theName): + aStudy = salome.myStudy + aId = 0 + aObj = aStudy.FindObjectByName(theName, "GEOM") + while len(aObj) != 0: + aId = aId + 1 + aName = theName + '_' + str(aId) + aObj = aStudy.FindObjectByName(aName, "GEOM") + return aId ## @ingroup Plugins # Feature to export all shapes and groups into the GEOM module @@ -40,6 +49,7 @@ class ExportFeature(ModelAPI.ModelAPI_Feature): ## Exports all bodies def exportBodies(self): + global ShapeIndex kResultBodyType = "Bodies" aPartSize = self.Part.size(kResultBodyType) if aPartSize == 0: @@ -56,7 +66,14 @@ class ExportFeature(ModelAPI.ModelAPI_Feature): aDump = aShape.getShapeStream() # Load shape to SALOME Geom aBrep = self.geompy.RestoreShape(aDump) - self.geompy.addToStudy(aBrep, "NewGeomShape_{0}".format(idx + 1)) + aName = aBodyResult.data().name() + + # Make unique name + aId = getObjectIndex(aName) + if aId != 0: + aName = aName + '_' + str(aId) + + self.geompy.addToStudy(aBrep, aName) self.geomObjects.append([aShape, aBrep]) ## Exports all groups @@ -69,8 +86,11 @@ class ExportFeature(ModelAPI.ModelAPI_Feature): aSelectionList = aFeature.data().selectionList("group_list") # if a group has been found if aSelectionList: + aFeature = ModelAPI.objectToFeature(aFeature) + if aFeature.firstResult() is not None: + aName = aFeature.firstResult().data().name() groupIndex = groupIndex + 1 - self.createGroupFromList(aSelectionList, "NewGeomGroup_{0}".format(groupIndex)) + self.createGroupFromList(aSelectionList, aName) ## Creates a group by given list of selected objects and the name # @param theSelectionList: list of selected objects