Cannot load .usd via python script into Omniverse XR

I am trying to load a .usd Scene via a Python script into Kit XR. I am getting the following errors:

When I just load the .usd file manually using the GUI it just loads fine. Any idea what causes the difference? All dependencies of the .usd file are there, incl. the sky texture etc…

That’s my command: C:\Users\dsbg\Omniverse Demo Projects\test\kit\kit.exe …/apps/omni.xr.kit --exec “./scripts/test_load_usd_ds2.py --path …/ov-industrial3dpack-01-100.1.1/Stages/IsaacWarehouse.usd”

I am using the following Python script to parse the command line and then load the given .usd file.

# loads a USD file and plays its timeline after load.
import argparse
import time
import threading
import omni.usd
import omni.timeline
import omni.kit.app

parser = argparse.ArgumentParser()
parser.add_argument("--path", help="Path to USD stage.")

options = parser.parse_args()


def on_open(*_):
    omni.timeline.acquire_timeline_interface().play()


omni.usd.get_context().open_stage_with_callback(options.path, on_open)

And that’s the kit file:

[package]
title = "Omniverse XR"
description = "XR Omniverse application"
version = "2022.1.0-rc.4"

# Search terms for "experience" filter
keywords = ["experience", "app", "VR", "XR", "HMD", "OpenVR", "Virtual Reality", "CloudXR", "SteamVR"]

[dependencies]
# the base App
"omni.app.xr.core" = {}

# Omniverse XR Dependencies
"omni.kit.xr.profile.tabletar" = {}
"omni.kit.xr.profile.vr" = {}

# XR splash / setup
# "omni.xr.splash" = { order = -5000 }
"omni.xr.app.setup" = { order = 1000 } # we are running that at the end
"omni.xr.app.resources" = {}
"omni.kit.splash" = { order = -5000}

# Environment
# "omni.kit.window.environment" = {}
# "omni.kit.property.environment" = {}
# "omni.kit.environment.core" = {}

# Environment settings
[settings.exts."omni.kit.environment.core"]
extraMdlParam = true
rtx.sky.auto = false

# Material Library
"omni.kit.material.library" = {}


[settings]

# Tooltips
persistent.xr.profile.vr.showTooltips = true

exts."omni.kit.browser.sample".folders = [
		"NVIDIA::http://omniverse-content-production.s3-us-west-2.amazonaws.com/Samples"
	]

# Privacy
################################
# Set privacy.externalBuild to true when you're working on an RC build
privacy.externalBuild = false
structuredLog.enable = false

# Splash Setup
################################
exts."omni.kit.window.splash".imagePath = "${omni.xr.app.resources}/data/XR_Splash_Screen@1x.png"
exts.'omni.kit.splash'.splash_app = "${omni.xr.app.setup}/apps/omni.xr.app.splash.kit"


# Hang Detector
################################
app.hangDetector.enabled = false
app.hangDetector.timeout = 120


# Localhost registry
[settings.exts."omni.kit.registry.nucleus"]
registries = [
   { name = "kit/public", url = "http://localhost:{local_port}/kit/registry"}
]

# Registry service
###############################
[settings.exts."omni.services.registry"]
registries = [
    { name = "kit/public", url = "s3://kit-103-0-public-extensions/public?public=true&region=us-east-2&verify_ssl=False" },
]

# hide NonToggleable Exts
[settings.exts.'omni.kit.window.extensions']
featuredExts = [
    "omni.kit.xr.common",
    "omni.kit.xr.vr.profile",
]

[settings.app.settings]
dev_build = false

[settings.app.window]
title = "Omniverse XR"
width = 1800
height = 940
x = -1
y = -1
iconPath = "${omni.xr.app.resources}/data/nvidia-omniverse-xr.ico"


[settings.exts."omni.kit.xr.common.profile.vr"]
vrsettingsmode_advanced = false
vrsettingsmode_debug = false

[settings.app.exts]
folders.'++' = ["${app}/", "${app}/../exts", "${app}/../extscache"]

[[test]]

name = "level-1"
args = [
	"--/app/window/width=480",
    "--/app/window/height=480",
    "--/app/file/ignoreUnsavedOnExit=true",
    "--/exts/omni.kit.window.viewport/blockingGetViewportDrawable=1",
    "--/exts/omni.kit.test/pyCoverageEnabled=0"
]
stdoutFailPatterns.exclude = [
    "*extension object is still alive*",
	"*Error *Animation_Camera_Animation* creating menu*",
	"*Failed while calling `shutdown_extensions` function*",
	"*KeyError:*Create*",
	"*Failed to acquire interface*IGpuFoundation*",
    "*ModuleNotFoundError: No module named 'omni.kit.property.usd'*",
    "*AttributeError: 'ContentBrowserExtension' object has no attribute '_window'*",
    "*IndexError: list index out of range*",
    "*Failed to create sky*",
]
pythonTests.include = [
	"omni.xr.app.setup.*",
]
timeout = 1200



########################################################################################################################
# BEGIN GENERATED PART (Remove from 'BEGIN' to 'END' to regenerate)
########################################################################################################################

# Kit SDK Version: 103.1+release.8073.0a16f6fe.tc
# Kit SDK dependencies:
# 	carb.audio-0.1.0
# 	carb.windowing.plugins-1.0.0
# 	omni.appwindow-1.0.0
# 	omni.assets.plugins-0.0.0
# 	omni.client-0.1.0
# 	omni.command.usd-1.0.1
# 	omni.gpu_foundation-0.0.0
# 	omni.hydra.engine.stats-1.0.0
# 	omni.hydra.rtx-0.1.0
# 	omni.hydra.scene_delegate-0.2.0
# 	omni.kit.agent-0.1.0
# 	omni.kit.async_engine-0.0.0
# 	omni.kit.audiodeviceenum-1.0.0
# 	omni.kit.commands-1.2.0
# 	omni.kit.context_menu-1.3.8
# 	omni.kit.loop-default-0.1.0
# 	omni.kit.mainwindow-0.0.0
# 	omni.kit.material.library-1.3.8
# 	omni.kit.menu.create-1.0.2
# 	omni.kit.menu.edit-1.0.5
# 	omni.kit.menu.file-1.0.7
# 	omni.kit.menu.utils-1.2.8
# 	omni.kit.notification_manager-1.0.5
# 	omni.kit.pip_archive-0.0.0
# 	omni.kit.pipapi-0.0.0
# 	omni.kit.primitive.mesh-1.0.0
# 	omni.kit.property.audio-1.0.5
# 	omni.kit.property.bundle-1.2.4
# 	omni.kit.property.camera-1.0.3
# 	omni.kit.property.geometry-1.2.0
# 	omni.kit.property.layer-1.1.2
# 	omni.kit.property.light-1.0.5
# 	omni.kit.property.material-1.8.2
# 	omni.kit.property.render-1.1.0
# 	omni.kit.property.skel-1.0.1
# 	omni.kit.property.transform-1.0.2
# 	omni.kit.property.usd-3.14.2
# 	omni.kit.quicklayout-1.0.1
# 	omni.kit.renderer.capture-0.0.0
# 	omni.kit.renderer.core-0.0.0
# 	omni.kit.renderer.init-0.0.0
# 	omni.kit.search_core-1.0.1
# 	omni.kit.selection-0.1.0
# 	omni.kit.splash-0.2.1
# 	omni.kit.stage_templates-1.1.2
# 	omni.kit.telemetry-0.1.0
# 	omni.kit.test-0.0.0
# 	omni.kit.uiapp-0.0.0
# 	omni.kit.usd_undo-0.1.0
# 	omni.kit.viewport.legacy_gizmos-1.0.0
# 	omni.kit.widget.browser_bar-2.0.3
# 	omni.kit.widget.filebrowser-2.2.25
# 	omni.kit.widget.graph-1.4.0
# 	omni.kit.widget.layers-1.5.16
# 	omni.kit.widget.path_field-2.0.3
# 	omni.kit.widget.prompt-1.0.1
# 	omni.kit.widget.settings-1.0.0
# 	omni.kit.widget.stage-2.6.13
# 	omni.kit.widget.stage_icons-1.0.2
# 	omni.kit.widget.versioning-1.3.6
# 	omni.kit.window.about-1.0.1
# 	omni.kit.window.console-0.2.0
# 	omni.kit.window.content_browser-2.4.21
# 	omni.kit.window.drop_support-1.0.0
# 	omni.kit.window.extensions-1.0.2
# 	omni.kit.window.file-1.3.14
# 	omni.kit.window.file_exporter-1.0.4
# 	omni.kit.window.file_importer-1.0.4
# 	omni.kit.window.filepicker-2.4.24
# 	omni.kit.window.popup_dialog-2.0.7
# 	omni.kit.window.preferences-1.2.1
# 	omni.kit.window.privacy-0.1.0
# 	omni.kit.window.property-1.6.3
# 	omni.kit.window.splash-0.0.0
# 	omni.kit.window.stage-2.3.6
# 	omni.kit.window.stats-0.1.1
# 	omni.kit.window.status_bar-0.1.1
# 	omni.kit.window.title-1.1.1
# 	omni.kit.window.toolbar-1.2.2
# 	omni.kit.window.viewport-0.0.0
# 	omni.renderer-rtx-0.0.0
# 	omni.rtx.settings.core-0.5.5
# 	omni.rtx.window.settings-0.6.1
# 	omni.stats-0.0.0
# 	omni.timeline-1.0.2
# 	omni.ui-2.9.2
# 	omni.uiaudio-1.0.0
# 	omni.usd-1.5.2
# 	omni.usd.config-1.0.0
# 	omni.usd.libs-1.0.0
# 	omni.usd.schema.anim-0.0.0
# 	omni.usd.schema.audio-0.0.0
# 	omni.usd.schema.omnigraph-1.0.0
# 	omni.usd.schema.physics-1.0.0
# 	omni.usd.schema.semantics-0.0.0

# Version lock for all dependencies:
[settings.app.exts]
enabled = [
	"omni.app.xr.core-2022.1.0",
	"omni.kit.xr.common-103.1.0",
	"omni.kit.xr.core-103.1.0",
	"omni.kit.xr.profile.tabletar-103.1.0",
	"omni.kit.xr.profile.vr-103.1.0",
	"omni.kit.xr.system.cloudxr21-103.1.0",
	"omni.kit.xr.system.playback-103.1.0",
	"omni.kit.xr.system.simulatedxr-103.1.0",
	"omni.kit.xr.system.steamvr-103.1.0",
	"omni.xr.app.resources-103.1.0",
	"omni.xr.app.setup-103.1.0",
]

########################################################################################################################
# END GENERATED PART
########################################################################################################################

Hi @daniel.seidl. This should be much improved in the next version of Kit. For now, you can do something like this to work around it:

import asyncio
...

def on_open(*_):
    omni.timeline.acquire_timeline_interface().play()

async def startup_script():
    await omni.usd.get_context().next_stage_event_async()

    omni.usd.get_context().open_stage_with_callback(options.path, on_open)

asyncio.ensure_future(startup_script())

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.