From: vsv Date: Fri, 6 Feb 2015 17:13:40 +0000 (+0300) Subject: Issue #398: Make exported shape name as unique X-Git-Tag: V_1.1.0~210^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=79615009ffcea2fc48e5619d403499d2b4b5ec25;p=modules%2Fshaper.git Issue #398: Make exported shape name as unique --- diff --git a/src/ConnectorPlugin/ConnectorPlugin_ExportFeature.py b/src/ConnectorPlugin/ConnectorPlugin_ExportFeature.py index c4bf4a6ae..9f2768e4c 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 @@ -57,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, aBodyResult.data().name()) + 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