Snapshots
Snapshots Tutorial.
This tutorial demonstrates how to capture screenshots from the Volvicon application using the available snapshot types.
Prerequisites
- Volvicon application must be running
- For some operations, a project with objects should be loaded
Snapshot Types​
# The API supports various snapshot types to capture different views:
#
# - api.SnapshotType.Application - Capture entire application window
# - api.SnapshotType.Scene - Capture the scene view
# - api.SnapshotType.View3D - Capture current 3D view
# - api.SnapshotType.View3D_NegativeX - 3D view from negative X axis
# - api.SnapshotType.View3D_PositiveX - 3D view from positive X axis
# - api.SnapshotType.View3D_NegativeY - 3D view from negative Y axis
# - api.SnapshotType.View3D_PositiveY - 3D view from positive Y axis
# - api.SnapshotType.View3D_NegativeZ - 3D view from negative Z axis
# - api.SnapshotType.View3D_PositiveZ - 3D view from positive Z axis
# - api.SnapshotType.View3D_Isometric - 3D isometric view
# - api.SnapshotType.Slice_LeftRight - Left-right slice view
# - api.SnapshotType.Slice_FrontBack - Front-back slice view
# - api.SnapshotType.Slice_TopBottom - Top-bottom slice view
Saving Snapshots to Disk​
# Save snapshots directly to file using save_snapshot_to_disk()
# Save 3D view to PNG file
output_path = r'C:\temp\view3d_snapshot.png'
# success = app.save_snapshot_to_disk(api.SnapshotType.View3D, output_path, "PNG")
# if success:
# print(f"Snapshot saved to: {output_path}")
# Save scene view as JPEG
# app.save_snapshot_to_disk(api.SnapshotType.Scene, r'C:\temp\scene.jpg', "JPEG")
# Save application window
# app.save_snapshot_to_disk(api.SnapshotType.Application, r'C:\temp\app.png', "PNG")
Standard Views​
# Capture views from standard orientations
# Front view (negative Y)
# app.save_snapshot_to_disk(api.SnapshotType.View3D_NegativeY, r'C:\temp\front.png', "PNG")
# Back view (positive Y)
# app.save_snapshot_to_disk(api.SnapshotType.View3D_PositiveY, r'C:\temp\back.png', "PNG")
# Left view (negative X)
# app.save_snapshot_to_disk(api.SnapshotType.View3D_NegativeX, r'C:\temp\left.png', "PNG")
# Right view (positive X)
# app.save_snapshot_to_disk(api.SnapshotType.View3D_PositiveX, r'C:\temp\right.png', "PNG")
# Top view (positive Z)
# app.save_snapshot_to_disk(api.SnapshotType.View3D_PositiveZ, r'C:\temp\top.png', "PNG")
# Bottom view (negative Z)
# app.save_snapshot_to_disk(api.SnapshotType.View3D_NegativeZ, r'C:\temp\bottom.png', "PNG")
# Isometric view
# app.save_snapshot_to_disk(api.SnapshotType.View3D_Isometric, r'C:\temp\isometric.png', "PNG")
Slice Views​
# Capture 2D slice views
# Sagittal slice (left-right)
# app.save_snapshot_to_disk(api.SnapshotType.Slice_LeftRight, r'C:\temp\sagittal.png', "PNG")
# Coronal slice (front-back)
# app.save_snapshot_to_disk(api.SnapshotType.Slice_FrontBack, r'C:\temp\coronal.png', "PNG")
# Axial slice (top-bottom)
# app.save_snapshot_to_disk(api.SnapshotType.Slice_TopBottom, r'C:\temp\axial.png', "PNG")
Getting Snapshot as Image Data​
# Use grab_snapshot() to get image data in memory
# Grab snapshot and get image data
# image = app.grab_snapshot(api.SnapshotType.View3D)
# print(f"Image size: {image.width} x {image.height}")
# print(f"Image format: {image.format}")
# Image data is available in image.data as bytes
Example: Capture Multiple Views​
def capture_all_standard_views(output_dir: str):
"""Capture all standard views to a directory."""
global api
views = [
(api.SnapshotType.View3D_NegativeX, "left"),
(api.SnapshotType.View3D_PositiveX, "right"),
(api.SnapshotType.View3D_NegativeY, "front"),
(api.SnapshotType.View3D_PositiveY, "back"),
(api.SnapshotType.View3D_NegativeZ, "bottom"),
(api.SnapshotType.View3D_PositiveZ, "top"),
(api.SnapshotType.View3D_Isometric, "isometric"),
]
for snapshot_type, name in views:
file_path = f"{output_dir}\\{name}.png"
success = app.save_snapshot_to_disk(snapshot_type, file_path, "PNG")
if success:
print(f"Saved: {file_path}")
# Uncomment to capture all views: Make sure the output directory exists
# capture_all_standard_views(r'C:\tmp\views')
print("Snapshots tutorial completed successfully.")
Related Resources​
- API Reference - API documentation
- Quick Reference - Common methods at a glance