How to convert .obj or .stl files to .mesh?

How to convert .obj or .stl files (or another CAD format) to .mesh?

I tried using:

  • Qt_3d_Studio
  • MeshLab
  • MeshMixer
  • Blender
  • KOMPAS-3D

but could not convert the file to .mesh format.


(base) comp@comp:~$ pip install meshio
Collecting meshio Downloading meshio-5.0.0-py3-none-any.whl (163 kB) |████████████████████████████████| 163 kB 200 kB/s
Requirement already satisfied: numpy in ./anaconda3/lib/python3.8/site-packages (from meshio) (1.18.5)
Installing collected packages: meshio
Successfully installed meshio-5.0.0
(base) comp@comp:~$ cd /home/comp/Qt/Examples/Qt-6.1.2/quick3d/view3d
(base) comp@comp:~/Qt/Examples/Qt-6.1.2/quick3d/view3d$ ls
CMakeLists.txt main_qml.o qml.qrc untitled.obj
doc Makefile qrc_qml_qmlcache.cpp view3d
main.cpp model.smesh qrc_qml_qmlcache.o view3d.pro
main.o qmlcache_loader.cpp teapot.mesh view3d.pro.user
main.qml qmlcache_loader.o untitled1.mtl
main_qml.cpp qml_qmlcache.qrc untitled1.obj
(base) comp@comp:~/Qt/Examples/Qt-6.1.2/quick3d/view3d$ meshio convert model1.obj output.mesh
Traceback (most recent call last): File "/home/comp/anaconda3/bin/meshio", line 8, in <module> sys.exit(main()) File "/home/comp/anaconda3/lib/python3.8/site-packages/meshio/_cli/_main.py", line 53, in main return args.func(args) File "/home/comp/anaconda3/lib/python3.8/site-packages/meshio/_cli/_convert.py", line 65, in convert mesh = read(args.infile, file_format=args.input_format) File "/home/comp/anaconda3/lib/python3.8/site-packages/meshio/_helpers.py", line 69, in read return reader_map[file_format](filename) File "/home/comp/anaconda3/lib/python3.8/site-packages/meshio/obj/_obj.py", line 19, in read mesh = read_buffer(f) File "/home/comp/anaconda3/lib/python3.8/site-packages/meshio/obj/_obj.py", line 93, in read_buffer return Mesh(points, cells, point_data=point_data) File "/home/comp/anaconda3/lib/python3.8/site-packages/meshio/_mesh.py", line 61, in __init__ raise ValueError(
ValueError: len(points) = 308908, but len(point_data["obj:vn"]) = 284573
(base) comp@comp:~/Qt/Examples/Qt-6.1.2/quick3d/view3d$ 
1

1 Answer

meshio seems capable of doing what you want (haven't tried it myself). You can install it by running:

pip install meshio

or

pip install 'meshio[all]'

([all] pulls in all optional dependencies. By default, meshio only uses numpy.)

After the installation is complete, you can run the following command to convert an .obj file to .mesh:

meshio convert input.obj output.mesh

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like