.. _d7.01.02-solution: Fichiers corrigés ================= Catalogue de commandes : .. code-block:: python from ..Commons import * from ..Language.DataStructure import * from ..Language.Syntax import * CONV_MAIL_MED = MACRO( nom="CONV_MAIL_MED", op=OPS("code_aster.MacroCommands.conv_mail_med_ops.conv_mail_med_ops"), sd_prod=table_sdaster, reentrant="n", fr=tr("Convertit un maillage ASTER, GMSH ou GIBI au format MED."), UNITE_IN=SIMP(statut="o", typ="I"), FORMAT_IN=SIMP(statut="f", typ="TXM", defaut="ASTER", into=("ASTER", "GIBI", "GMSH")), UNITE_OUT=SIMP(statut="f", typ="I", defaut=80), INFO=SIMP(statut="f", typ="I", into=(1, 2), defaut=1), ) Corps de la macro-commande ``code_aster/MacroCommands/conv_mail_med_ops.py`` : .. code-block:: python from ..Cata.Syntax import _F from ..CodeCommands import CREA_TABLE, IMPR_RESU, LIRE_MAILLAGE from ..Messages import UTMESS def conv_mail_med_ops(self, UNITE_IN, FORMAT_IN, UNITE_OUT, **args): """Convert a mesh from ASTER, GMSH ou GIBI format to MED format and return some mesh properties. Arguments: **args (dict): User's keywords. Returns: Table: Object containing some characteristics of the mesh. """ args = _F(args) info = args.get("INFO", 1) # INFO is mandatory so: # info = args["INFO"] # or adding INFO in arguments also works # print the information message UTMESS("I", "MESH_1", valk=FORMAT_IN, vali=(UNITE_IN, UNITE_OUT)) # read the input mesh mesh = LIRE_MAILLAGE(FORMAT=FORMAT_IN, UNITE=UNITE_IN, INFO=info) # write the mesh into a MED file IMPR_RESU(FORMAT="MED", UNITE=UNITE_OUT, RESU=_F(MAILLAGE=mesh)) # extract some mesh characteristics nbnodes = mesh.getNumberOfNodes() nbcells = mesh.getNumberOfCells() # fill the output table tab = CREA_TABLE( LISTE=( _F(PARA=("NB_NOEUDS",), LISTE_I=(nbnodes,)), _F(PARA=("NB_MAILLES",), LISTE_I=(nbcells,)), ) ) return tab