1 # Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
22 # File : SMESH_test1.py
32 def SetSObjName(theSObj,theName) :
33 ok, anAttr = theSObj.FindAttribute("AttributeName")
35 aName = anAttr._narrow(SALOMEDS.AttributeName)
37 aName.SetValue(theName)
39 def ConvertMED2UNV(thePath,theFile) :
40 anInitFileName = thePath + theFile
41 aMeshes,aResult = smesh.CreateMeshesFromMED(anInitFileName)
42 print aResult, aMeshes
44 for iMesh in range(len(aMeshes)) :
45 aMesh = aMeshes[iMesh]
46 anSObj = salome.ObjectToSObject(aMesh)
47 print anSObj.GetName(),
48 aFileName = anInitFileName
49 aFileName = os.path.basename(aFileName)
50 SetSObjName(anSObj,aFileName)
51 print anSObj.GetName()
53 aFileName = thePath + theFile + "." + str(iMesh) + ".unv"
54 aMesh.ExportUNV(aFileName)
55 aMesh = smesh.CreateMeshesFromUNV(aFileName)
56 anSObj = salome.ObjectToSObject(aMesh)
57 print anSObj.GetName(),
59 aFileName = os.path.basename(aFileName)
60 SetSObjName(anSObj,aFileName)
61 print anSObj.GetName()
63 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
64 smesh.SetCurrentStudy(salome.myStudy)
66 aPath = os.getenv('KERNEL_ROOT_DIR') + '/examples/'
67 aListDir = os.listdir(aPath)
70 for iFile in range(len(aListDir)) :
71 aFileName = aListDir[iFile];
72 aName,anExt = os.path.splitext(aFileName)
74 aFileName = os.path.basename(aFileName)
76 ConvertMED2UNV(aPath,aFileName)
79 salome.sg.updateObjBrowser(1);