如何将.obj 或 .stl 文件转换为 .mesh?

如何将.obj 或 .stl 文件转换为 .mesh?

如何将.obj.stl文件(或其他 CAD 格式)转换为.mesh

我尝试使用:

  • qt_3d_studio
  • 网格实验室
  • 网状混合器
  • 搅拌机
  • 罗盘-3D

但无法将文件转换为.mesh格式。


(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

meshio似乎可以完成您想要的操作(我自己还没有尝试过)。您可以通过运行以下命令来安装它:

pip install meshio

或者

pip install 'meshio[all]'

[all]引入所有可选依赖项。默认情况下,meshio仅使用 numpy。)

安装完成后,您可以运行以下命令将文件转换.obj.mesh

meshio convert input.obj output.mesh

相关内容