From 79615009ffcea2fc48e5619d403499d2b4b5ec25 Mon Sep 17 00:00:00 2001 From: vsv Date: Fri, 6 Feb 2015 20:13:40 +0300 Subject: [PATCH] Issue #398: Make exported shape name as unique --- .../ConnectorPlugin_ExportFeature.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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 -- 2.39.2