CreatePayloadCommand does not work first time when called from an extension

Experts,

  I have a need to load a usd file belonging to a plant model into the viewport, via a custom extension/app. If I use the below command in the script editor and run, the usd file gets loaded without any issue

omni.kit.commands.execute(“CreatePayload”,
usd_context=omni.usd.get_context(),
path_to=Sdf.Path(“/World/bugatti”),
asset_path=“D:/test/bugatti.usd”,
instanceable=False
)

However if I try to achieve the same thing by putting the above code in a custom extension (added this on on_startup()), nothing happens when I run my app for the first time. But, when I go back and do some change and save my extension, I see my usd getting loaded. I am not sure why it does not load the first time but requires an explicit save action in the extension to trigger the loading of the file.

Attaching the extension.py code. Appreciate if anyone can let me know what am I doing wrong here.
extension.py (1.4 KB)

This is because your extension is loading before the app is fully started. USD Composer, for example, has startup logic that opens a default scene. Your payload is being created and then discarded when the default scene is loaded. I would move this out of the on_startup().

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