pyvista / pyvista-support

[moved] Please head over to the Discussions tab of the PyVista repository
https://github.com/pyvista/pyvista/discussions
60 stars 4 forks source link

Exporting mesh with interpolation color #370

Open joshemmitt opened 3 years ago

joshemmitt commented 3 years ago

PGXRF.zip I have a Juypter notebook attached here in which I have added a custom mesh with points with values, which I have used with the interpolation tool to color the mesh. I wish to export the mesh as a ply or some other form of 3d format with the interpolated colors on it either as face or vertex colors. When I export it as it is coded now, it only exports a mesh with no color. Would someone please be able to point out what I have done wrong? Thank you in advance for any help.

akaszynski commented 3 years ago

Store the colors as a point array within the mesh (i.e. mesh.point_arrays['my_values']) and then export it as a vtk file. You can then load that back in and plot it with:

import pyvista as pv
pv.plot(mesh, scalars='my_values')
joshemmitt commented 3 years ago

Thank you for that. It looks like it will work but the one thing I can't figure out (please excuse my ignorance) is when I use the interpolate function on the mesh what the 'my_values' should be called as. Because also whatever I try in there I get a 'DataSetAttributes' object is not callable error.

akaszynski commented 3 years ago

Could you post a minimum working example here within GitHub please?