trimeshgmsh

Access mesh imported with gmsh


I think I have a very common problem. Can you help me out? I want to examine a 3D-mesh with python. I want to use trimesh in order to examine the mesh but the mesh comes with the .STEP Format. I use gmsh to load the mesh but I have no idea how I can access the mesh I have or how I can convert it into a trimesh.mesh.

Can you help me out? My code looks like this so far:

import trimesh
import gmsh
import pygmsh

gmsh.initialize()
gmsh.option.setNumber("General.Terminal", 1)
gmsh.model.add("modelo_1")

gmsh.merge(
    "C:/Users/PythonFan/RandomFile.STEP")
gmsh.model.mesh.generate(3)

[...]

x.center_mass

So how do I get from here to there?


Solution

  • I found I what I have to do :D

    x = trimesh.Trimesh(**trimesh.interfaces.gmsh.load_gmsh("C:/Users/....STEP")
    

    This allows me to use use the gmsh loading abilities while examining the object with trimesh. I'll post my source once I found it again.