Saving mesh_plot to image? #9
-
I'm trying to get an isometric view of an stl and save it to an image. Is there any way to orient the mesh to see all 3 planes? Any examples of how to use image_io.write to save a vpl.mesh_plot to a png or jpg? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
For setting camera angles use view(). There's nothing special dedicated to isometric views but it's only a two-liner anyway: vpl.view(camera_direction=[1, 1, 1])
vpl.reset_camera() As for generating images, you save figures using save_fig(). Glueing those two together, your code should look something like: import vtkplotlib as vpl
# Plot the rabbit. Replace this with your own mesh.
vpl.mesh_plot(vpl.data.get_rabbit_stl())
# Set the camera angle. Toggle the minus signs to switch views.
vpl.view(camera_direction=[-1, 1, 1])
# Let VTK choose a sensible zoom.
vpl.reset_camera()
# Take an snapshot and save it.
vpl.save_fig("image.jpg", pixels=(600, 600), off_screen=True)
# Add as many view() and save_fig() calls as you need...
# Close the figure.
vpl.close() I've used the rabbit for convenience although it's not a very good example because the model is at some odd angle. |
Beta Was this translation helpful? Give feedback.
For setting camera angles use view(). There's nothing special dedicated to isometric views but it's only a two-liner anyway:
As for generating images, you save figures using save_fig().
Glueing those two together, your code should look something like: