How to export mesh as .msh file from Mechanical using PyMechanical
Hi all,
I'm trying to export a mesh file in .msh format from a session of Mechanical 2024 R2 using PyMechanical. I've found this post, and tried to implement the solution:
But when I try to use the line:ExtAPI.DataModel.Project.Model.Mesh.InternalObject.WriteFluentInputFile(r"D:\FluentMesh.msh")
I get the following error:
'__ComObject' object has no attribute 'WriteFluentInputFile'
And if I try dir(ExtAPI.DataModel.Project.Model.Mesh.InternalObject), I can in fact see there is no attribute 'WriteFluentInputFile'.
dir(ExtAPI.DataModel.Project.Model.Mesh.InternalObject)
['CreateObjRef', 'Equals', 'Finalize', 'GetHashCode', 'GetLifetimeService', 'GetType', 'InitializeLifetimeService', 'MemberwiseClone', 'Overloads', 'ReferenceEquals', 'ToString', 'class', 'delattr', 'dir', 'doc', 'eq', 'format', 'ge', 'getattribute', 'gt', 'hash', 'init', 'init_subclass', 'le', 'lt', 'module', 'ne', 'new', 'overloads', 'reduce', 'reduce_ex', 'repr', 'setattr', 'sizeof', 'str', 'subclasshook']
Does anyone know why this is happening and what the correct way to export the mesh would be?
Thanks!
Kyle
Comments
-
Did you try using the jscript method?:
FilePath = r"D:\FluentMeshFromWB.msh" JScmds = '''var DS = WB.AppletList.Applet('DSApplet').App; DS.Script.doFileExport("{}");'''.format(FilePath) ExtAPI.Application.ScriptByName("jscript").ExecuteCommand(JScmds)
If that doesn't work, can you post more details? (e.g. Are you running remote or embedded PyMechanical? What version of PyMechanical?)
0