1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

3Dモデルのフォーマット変換(PyVista)

Last updated at Posted at 2024-11-08

PyVistaを用いて3Dモデルを変換します

コード

model_transfar.py
import pyvista as pv

in_filename = 'input.stl'
out_filename = 'output.vtk'
reader = pv.get_reader(in_filename)
mesh = reader.read()
mesh.save(out_filename)

1 : pv.get_reader()でフォーマットに合わせた読み込み関数を呼び出し
2 : reader.read()でメッシュを読み込みmeshに格納
3 : mesh.save()でフォーマットに合わせて書き込み

対応拡張子

入力側
'.obj''.stl''.vtk'など[2]

出力側
'.vtp''.stl''.vtk'.geo''.obj''.iv'

参考

[1]https://tutorial.pyvista.org/index.html
[2]https://tutorial.pyvista.org/tutorial/02_mesh/solutions/e_read-file.html
[3]https://docs.pyvista.org/api/readers/_autosummary/pyvista.objreader
[4]https://docs.pyvista.org/api/core/_autosummary/pyvista.polydata.save

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?