Build 3D mesh using Pyvista

0 65
Avatar for Hyperchain
1 year ago

Pyvista is 3D data management and visualization software which you could build an interactive 3d mesh using python, pyvista was built on the top of vtkplotlib where it makes it more easy to visualize 3d model than vtk, pyvista was aim to visualize 3D geoscientific data and models in a common geo-referenced framework.

So in this tutorial we are going to give a simple quickstart to work with pyvista to give you an insight how it works.

So without further ado let's get started on:

first install pyvista using pip

>> pip install pyvista
# import packages
import pyvista 
import pyvista as pv
from pyvista import examples

the pyvista module has an example file which contains the 3D object

dataset = examples.load_uniform()
dataset.plot()

this is it much easier, now if you want to take a screenshot without creating an interactive plot window you need to use plotter:

plotter = pv.Plotter(off_screen=True)

plotter.add_mesh(mesh)
plotter.show(screenshot="myscreenshot.png")

you could also change the background color into dark by using this function

pyvista.set_plot_theme('dark')

So, as you can see pyvista is much easier to work with which you can use in more real-life work, this tutorial is short about pyvista in the next tutorial we are going to go in depth about pyvista so stay tuned .

1
$ 0.00
Avatar for Hyperchain
1 year ago

Comments