2 # -*- coding: iso-8859-1 -*-
3 # Copyright (C) 2007-2014 CEA/DEN, EDF R&D
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 # Author : Anthony GEAY (CEA/DEN/DM2S/STMF/LGLS)
23 from MEDLoader import MEDFileData,InterpKernelException
24 from CaseWriter import CaseWriter
25 from optparse import OptionParser
28 parser = OptionParser()
29 parser.set_usage("Convert a MED file to a Case file.\n %prog [options] med_file")
30 parser.add_option("-g", "--groups", action="store_true", dest="groups", default=False,
31 help="Are groups in meshes stored in MEDFile exported in output case as subparts (default False)")
32 parser.add_option("-c", "--currentdir", action="store_true", dest="here", default=False,
33 help="Are generated case,geo files generated in current directory. By default not, files are generated in directory containing the input file (default False)")
34 (opts, args) = parser.parse_args()
41 fname=os.path.abspath(args[0]) #"cas_test_simple.case"
43 fOut=os.path.splitext(os.path.basename(fname))[0]+".case"
46 fOut=os.path.splitext(fname)[0]+".case"
51 cw.setExportingGroups(opts.groups)
52 mfd=MEDFileData(fname)
54 listOfWrittenFileNames=cw.write(fOut)
55 except InterpKernelException as e:
56 print "An error occurred during the conversion!"
57 print "#######################################"
60 for l in listOfWrittenFileNames:
61 print "File \"%s\" successfully written !"%(l)