Saving mesh_plot to image? #9
Answered
by
bwoodsend
3deo-chris
asked this question in
Q&A
|
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? |
Answered by
bwoodsend
Jun 28, 2021
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. |
0 replies
Answer selected by
3deo-chris
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: