如何将.obj
或.stl
文件(或其他.mesh
格式)转换为D2
?
我试着用:
但无法将文件转换为.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
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$
发布于 2021-08-08 14:57:48
meshio
似乎有能力做你想做的事情(我还没试过)。您可以通过运行以下命令来安装:
pip install meshio
或
pip install 'meshio[all]'
([all]
引入所有可选的依赖项。默认情况下,meshio
只使用numpy。)
安装完成后,可以运行以下命令将.obj
文件转换为.mesh
:
meshio convert input.obj output.mesh
https://askubuntu.com/questions/1356695
复制相似问题