How to open a stage ("omni.kit.window.file.open_stage(path_to_open)" with payloads deactivated

I am developing an extension for OV View in Omniverse Create.
I have taken as reference the Extension omni.view.startup, and I am trying to modify the script.
In the function async_open_stage, I want to load the scene without payloads.

async def _async_open_stage(self, path_to_open):
        # waiting the content window invisible
         omni.kit.window.file.open_stage(path_to_open) # THIS LINE IS THE ONE I WANT TO MODIFY TO OPEN WITHOUT PAYLOADS

In the documentation I have found the following interesting information, but I am not able to make it work.
open_stage(path, open_loadset=UsdContextInitialLoadSet.LOAD_ALL, open_options: Optional[omni.kit.window.file.scripts.app_ui.OpenOptionsDelegate] = None)

This Error Message may also help: “.py:1308> exception=AttributeError(”‘StartupExtension’ object has no attribute ‘_load_payload_checkbox’")> "

When trying different solutions, I allways get the Error Message in Console: [Error] [omni.kit.window.file.scripts.file_window] Only one file task can be run at a time!

Any idea of how can I do this?
Thanks in advance.

Hi @Jav_SC! Welcome to the forums.

The loadset you want is: UsdContextInitialLoadSet.LOAD_NONE,but the particular function you’re call maybe does more than what you need.

Give this a try:

# Synchronous version
import omni.usd
omni.usd.get_context().open_stage(path_to_usd_file, load_set=omni.usd.UsdContextInitialLoadSet.LOAD_NONE)
# Async version
import asyncio
import carb
import omni.usd

async def open_stage():
	result, error = await omni.usd.get_context().open_stage_async(path_to_usd_file, load_set=omni.usd.UsdContextInitialLoadSet.LOAD_NONE)
	stage = omni.usd.get_context().get_stage()
	carb.log_info(f"Opened stage {stage} with result {result}")

Let me know how that goes for you.

1 Like

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