Skip to main content

Getting Started

Application Basics 📥 Download Script

Getting Started with the Scripting API.

This tutorial introduces the basic concepts and usage patterns of the Scripting API. It covers creating an Application instance, accessing version information, working with projects, and displaying messages to the user.

Prerequisites
  • Volvicon application must be running
  • A valid license must be active
Quick Tips
  • Instantiate the Application: app = api.Application()
  • Use snake_case or descriptive names for variables (e.g., app, volume_operations, ai_segmentation).
  • Hover over the variable to view available methods and properties. If no tooltip appears, IntelliSense does not recognize the variable name. For details, refer to the documentation.
  • All API calls require positional arguments; keyword arguments are not supported.
  • Example:
  • mask_operations = app.get_mask_operations()
  • mask_operations.smooth_mean_filter([mask], 1, 1, 1)

Creating an Application Instance​

# The Application class is the primary entry point for interacting with Volvicon.
# Create an instance to access all API functionality.
#
# For better IntelliSense support, use one of these variable names:
# - app
# - application
# - Application
app = api.Application()

Version Information​

# Get the current version of the application
version = app.get_version()
print(f"Volvicon Version: {version}")

# Get the current working directory
working_dir = app.get_working_directory()
print(f"Working Directory: {working_dir}")

Message Box Display​

# Display informational, warning, and error messages to the user

# Information message (default level)
app.show_message_box(
"This is an informational message.",
"Information"
)

# Warning message
app.show_message_box(
"This is a warning message.",
"Warning",
api.MsgBoxLevel.Warn
)

# Error message
app.show_message_box(
"This is an error message.",
"Error",
api.MsgBoxLevel.Error
)

Question Dialog​

# Display a yes/no question dialog and get user response
response = app.show_question_message_box(
"Do you want to continue with this tutorial?",
"Confirmation"
)

if response:
print("User clicked Yes")
else:
print("User clicked No")

Message Box Suppression​

# A message box blocks the script until somebody clicks a button. That is fine
# while you sit in front of the application, but it stalls a script that runs
# unattended, for example one started with the --py_script command line option.
#
# Suppression lets the script keep going. Every skipped message box is printed
# on this console and written to the application log, so you still see what the
# application had to say.
#
# Available modes:
# - api.MsgBoxSuppression.Off Show every message box. This is the default.
# - api.MsgBoxSuppression.Notifications Skip the boxes that only have to be
# acknowledged. Boxes that ask you to
# choose between outcomes are still shown.
# - api.MsgBoxSuppression.All Skip every box. Each question is answered
# with its default button.

# Read the mode currently in effect
print(f"Message box suppression: {app.get_message_box_suppression()}")

# Skip the boxes that only report something, and keep confirmations interactive
app.set_message_box_suppression(api.MsgBoxSuppression.Notifications)

# This message is printed on the console instead of opening a dialog
app.show_message_box(
"This message is reported on the console because suppression is on.",
"Information"
)

# Careful: this mode also answers confirmations for you. Check the default
# action of each confirmation before enabling this mode.
# app.set_message_box_suppression(api.MsgBoxSuppression.All)

# Back to normal. This is not strictly needed, because the mode is restored
# automatically once the script finishes, but it keeps the intent clear.
app.set_message_box_suppression(api.MsgBoxSuppression.Off)

Project Management​

# Projects contain all objects (volumes, masks, surfaces, etc.)

# Close any currently open project
app.close_project()

# Open an existing project (modify the path to an existing project file)
# Supported format: .vvcx (Volvicon project file)
# project_path = r'C:\path\to\your\project.vvcx'
# success = app.open_project(project_path)
# if success:
# print("Project opened successfully")
# else:
# print("Failed to open project")

# Save the current project
# - If a path is provided, saves to that location
# - If empty string, saves to the current project location
# app.save_project() # Save to current location
# app.save_project(r'C:\path\to\new_project.vvcx') # Save to new location

# Get the current project file path
# Returns an empty string when no project file is associated with the session
current_project_path = app.get_project_file_path()
if current_project_path:
print(f"Current Project File: {current_project_path}")
else:
print("No project file is currently associated with the session")

Undo and Redo​

# The API supports undo/redo for most operations

# Undo the last action
# app.undo()

# Redo the last undone action
# app.redo()

Accessing Operations Objects​

# The Application provides access to specialized operations objects

# Volume operations - for working with 3D volume images
volume_operations = app.get_volume_operations()

# Mask operations - for working with segmentation masks
mask_operations = app.get_mask_operations()

# Surface operations - for working with 3D surface meshes
surface_operations = app.get_surface_operations()

# Volume mesh operations - for working with tetrahedral meshes
volume_mesh_operations = app.get_volume_mesh_operations()

# FEM operations - for material, set, and export operations on volume meshes
fem_operations = app.get_fem_operations()

# Measurement operations - for creating and analyzing measurements
measurement_operations = app.get_measurement_operations()

# Primitive operations - for creating and managing primitive or ROI objects
primitive_operations = app.get_primitive_operations()

# Registration operations - for aligning objects and datasets
registration_operations = app.get_registration_operations()

# Analysis operations - for creating and running analysis objects
analysis_operations = app.get_analysis_operations()

# Measure operations - for statistics, histograms, and measurements
measure_operations = app.get_measure_operations()

# AI segmentation - for AI-powered image segmentation
ai_segmentation = app.get_ai_segmentation()

# View operations - for layout, camera, and rendering control
view_operations = app.get_view_operations()

# Preferences operations - for reading and updating application preferences
preferences_operations = app.get_preferences_operations()

print("Getting started tutorial completed successfully.")