Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export mesh in .msh fileformat #206

Closed
Walshaikhli opened this issue Aug 18, 2018 · 3 comments
Closed

Export mesh in .msh fileformat #206

Walshaikhli opened this issue Aug 18, 2018 · 3 comments

Comments

@Walshaikhli
Copy link

First, thank you for maintaining Trimesh, I have used it for a day so far and it's an amazing tool! I wish i knew it existed a year ago!

I was wondering if I can export .msh files directly from Trimesh, this is the GMSH program format, and it's used in the state of the art EM solvers such as SCUFF-EM. I can use GMSH to convert to .msh but I'm hoping to use Trimesh for it.

Here is what I'm doing:
trimesh.io.export.export_mesh(mesh,'outputFile', file_type="msh")

Here is the error I get:

ValueError Traceback (most recent call last)
in ()
----> 1 trimesh.io.export.export_mesh(mesh,'outputFile', file_type="msh")

~\Anaconda3\lib\site-packages\trimesh\io\export.py in export_mesh(mesh, file_obj, file_type, **kwargs)
39
40 if not (file_type in _mesh_exporters):
---> 41 raise ValueError('%s exporter not available!', file_type)
42
43 log.debug('Exporting %d faces as %s', len(mesh.faces), file_type.upper())

ValueError: ('%s exporter not available!', 'msh')

@mikedh
Copy link
Owner

mikedh commented Aug 18, 2018

Hey, glad you're liking it!

Currently msh doesn't have any importers/exporters in trimesh. On the upside, the format is very well specified and looks pretty easy to implement. If I get a chance I'll take a look at doing it, but if you're feeling energetic and want to PR here's the punch list for supporting it:

  • add a <200kB test model of ASCII MSH in /models/
  • add a <200kB test model of Binary MSH in /models
  • add Binary/ASCII importer and Binary exporter to /trimesh/io/msh.py (either ply.py or stl.py might be good templates) that uses np.fromstring / np.frombuffer for key calls to avoid being mega slow. It might have to reject input meshes with elements other than triangles or quads.
  • Add unit tests to test_export.py, and also possibly check the validity of our exports using a subprocess call to gmsh

@mikedh
Copy link
Owner

mikedh commented Dec 21, 2018

Added to enhancements list. Thanks for the report!

@selvakarna
Copy link

Hi mikedh ,
I have Error while Create STL from X Y Z co-ordinates using Trimesh.

Can you share sample code for STL Creation , from X Y Z coordinates, [Faces and vertices from Trimesh]?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants