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

Hi,
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 startup.py 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
        await omni.kit.app.get_app().next_update_async()
         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.

https://docs.omniverse.nvidia.com/py/kit/source/extensions/omni.kit.window.file/docs/index.html
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.

1 Like

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}")
asyncio.ensure_future(open_stage())

Let me know how that goes for you.

2 Likes

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