Python Usage Examples#

Simple Time-Based Progress#

Shows a progress bar that fills based on elapsed time. Perfect for operations where you know approximately how long something will take.

Here is an example of progress with dynamic updates

import time
import omni.activity.freeze_progress as freeze_progress

freeze_progress.start_time_based(
    duration=12.0,
    activity="Stage 1: Initialization"
)

time.sleep(3)
freeze_progress.update_activity("Stage 2: Loading Assets")

time.sleep(3)
freeze_progress.update_activity("Stage 3: Building Scene")

time.sleep(3)
freeze_progress.update_activity("Stage 4: Finalizing")

time.sleep(3)
freeze_progress.stop_time_based()

Time-Based Progress with Tips#

Shows progress with helpful tips displayed below the progress bar. Tips rotate automatically to keep users informed during long operations.

import time
import omni.activity.freeze_progress as freeze_progress

# Define helpful tips to display
tips = [
    "Use Ctrl+S to save your work frequently",
    "Press F to frame selected objects in viewport",
    "Hold Alt and drag to orbit the camera",
    "Use G to toggle grid visibility",
    "Press V to toggle viewport statistics",
    "Shift+click to add to selection",
    "Press H to hide selected objects"
]

print("\nShowing progress with rotating tips...")

freeze_progress.start_time_based(
    duration=20.0,
    activity="Optimizing Scene",
    tips=tips,
    tip_duration=3.0  # Each tip shows for 3 seconds
)

# Simulate work while tips rotate
time.sleep(20)

freeze_progress.stop_time_based()

Event-Based Progress#

Shows progress based on actual activity events being tracked. The progress bar updates as USD files, textures, and materials are processed.

import time
import omni.activity.core as act
import omni.activity.freeze_progress as freeze_progress

# Start progress window - it will track activity events
freeze_progress.start()

# Enable activity tracking
act.enable()

# Simulate loading USD files
print("\nLoading USD files:")
usd_files = ["scene.usd", "props.usd", "lights.usd"]

for filename in usd_files:
    activity_path = f"USD|Read|{filename}"
    print(f"  - {filename}")

    act.began(activity_path)
    time.sleep(1.0)  # Simulate loading time
    act.ended(activity_path)

# Simulate loading textures
print("\nLoading textures:")
textures = ["diffuse.dds", "normal.dds", "roughness.dds"]

for texture in textures:
    activity_path = f"Textures|Load|{texture}"
    print(f"  - {texture}")

    act.began(activity_path)
    time.sleep(0.8)  # Simulate loading time
    act.ended(activity_path)

# Simulate processing materials
print("\nProcessing materials:")
materials = ["metal", "glass", "plastic"]

for material in materials:
    activity_path = f"Materials|Setup|{material}"
    print(f"  - {material}")

    act.began(activity_path)
    time.sleep(0.6)  # Simulate processing time
    act.ended(activity_path)

# Keep window open briefly to show completion
time.sleep(2)

# Cleanup
act.disable()
freeze_progress.stop()

Adaptive Progress#

Shows how the progress bar adapts when operations take longer than expected. After 80%, the progress slows down gracefully instead of stopping abruptly. Notice how the progress bar adapted to the longer duration!

import time
import omni.activity.freeze_progress as freeze_progress

# Start progress with 10 second estimate
freeze_progress.start_time_based(
    duration=10.0,
    activity="Processing (may take longer than expected)"
)

# Run for 15 seconds (50% longer than estimate)
# The progress will slow down after 80% to handle the overrun gracefully
for i in range(15):
    print(f"  {i+1}/15 seconds elapsed...")
    time.sleep(1)

freeze_progress.stop_time_based()

Mixed Mode Usage#

Shows how to switch between event-based and time-based progress for different phases of an operation.

import time
import omni.activity.core as act
import omni.activity.freeze_progress as freeze_progress

freeze_progress.start()
act.enable()

files = ["main.usd", "textures.dds", "materials.mdl"]
for file in files:
    if file.endswith(".usd"):
        path = f"USD|Read|{file}"
    elif file.endswith(".dds"):
        path = f"Textures|Load|{file}"
    else:
        path = f"Materials|Setup|{file}"

    print(f"  Loading {file}")
    act.began(path)
    time.sleep(1)
    act.ended(path)

act.disable()
freeze_progress.stop()

time.sleep(1)

# Phase 2: Time-based for processing
print("\nPhase 2: Processing data (time-based)")
print("-" * 30)

freeze_progress.start_time_based(
    duration=8.0,
    activity="Optimizing geometry"
)

print("  Processing...")
time.sleep(4)

freeze_progress.update_activity("Building acceleration structures")
time.sleep(4)

freeze_progress.stop_time_based()