-
Notifications
You must be signed in to change notification settings - Fork 9
/
converter.py
26 lines (20 loc) · 1.24 KB
/
converter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#pip install trimesh[easy]
#pip install gmsh-sdk
import trimesh
#General info found on https://trimsh.org/trimesh.interfaces.gmsh.html
#Returns a surface mesh from CAD model in Open Cascade Breap (.brep), Step (.stp or .step) and Iges formats Or returns a surface mesh from 3D volume mesh using gmsh.
#For a list of possible options to pass to GMSH, check: http://gmsh.info/doc/texinfo/gmsh.html
mesh = trimesh.Trimesh(**trimesh.interfaces.gmsh.load_gmsh(file_name = 'helical bevel gear.STEP', gmsh_args = [
("Mesh.Algorithm", 1), #Different algorithm types, check them out
("Mesh.CharacteristicLengthFromCurvature", 50), #Tuning the smoothness, + smothness = + time
("General.NumThreads", 10), #Multithreading capability
("Mesh.MinimumCirclePoints", 32)]))
## Visualize the formed mesh (applicable if on jupyter notebook)
#scene = mesh.scene()
#scene.show()
## We can also get some properties of the formed mesh like volume, bounding box volume, surface area etc (default output in mm)
print("Mesh volume: ", mesh.volume)
print("Mesh Bounding Box volume: ", mesh.bounding_box_oriented.volume)
print("Mesh Area: ", mesh.area)
## Export the new mesh in the STL format
mesh.export('helical bevel gear_converted.STL')