Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 import salome
00028 import smesh
00029 import SALOMEDS
00030 import CORBA
00031 import os
00032 import os.path
00033
00034 smesh.SetCurrentStudy(salome.myStudy)
00035
00036 def SetSObjName(theSObj,theName) :
00037 ok, anAttr = theSObj.FindAttribute("AttributeName")
00038 if ok:
00039 aName = anAttr._narrow(SALOMEDS.AttributeName)
00040
00041 aName.SetValue(theName)
00042
00043 def ConvertMED2UNV(thePath,theFile) :
00044 anInitFileName = thePath + theFile
00045 aMeshes,aResult = smesh.CreateMeshesFromMED(anInitFileName)
00046 print aResult, aMeshes
00047
00048 for iMesh in range(len(aMeshes)) :
00049 aMesh = aMeshes[iMesh]
00050 print aMesh.GetName(),
00051 aFileName = anInitFileName
00052 aFileName = os.path.basename(aFileName)
00053 aMesh.SetName(aFileName)
00054 print aMesh.GetName()
00055
00056 aOutPath = '/tmp/'
00057 aFileName = aOutPath + theFile + "." + str(iMesh) + ".unv"
00058 aMesh.ExportUNV(aFileName)
00059 aMesh = smesh.CreateMeshesFromUNV(aFileName)
00060 print aMesh.GetName(),
00061 os.remove(aFileName)
00062 aFileName = os.path.basename(aFileName)
00063 aMesh.SetName(aFileName)
00064 print aMesh.GetName()
00065
00066 aPath = os.getenv('DATA_DIR') + '/MedFiles/'
00067 aListDir = os.listdir(aPath)
00068 print aListDir
00069
00070 for iFile in range(len(aListDir)) :
00071 aFileName = aListDir[iFile]
00072 aName,anExt = os.path.splitext(aFileName)
00073 if anExt == ".med" :
00074 aFileName = os.path.basename(aFileName)
00075 print aFileName
00076 ConvertMED2UNV(aPath,aFileName)
00077
00078
00079 salome.sg.updateObjBrowser(1)