Import Asset through console/python

Hi, is there a way to import an usd asset through the script editor?

So short answer is, YES! However, that is where my expertise ends. I contacted the Kit development team to help us out. Have you had a chance to look at our Kit Programming Manual?

Hi! It should be something as simple as getting the context and calling open_stage*:

import omni.usd
omni.usd.get_context().open_stage_with_callback(path, None)

Please refer to “omni.usd module” section in the documentation WendyGram posted above for furter API details.

Hi, thanks for the quick response. However (O cannot try it now sorry) this seems to open a stage, not to load the USD within the current scene. Is this correct? I want to do the latter, so having a USD with the environment for example, and programmatically load prim/USD inside the scene.

Hello @marc2002! The development team got back to me with some coding help. This code will create a reference.

import omni.kit.commands
from omni import usd

omni.kit.commands.execute('CreateReferenceCommand',
      usd_context=omni.usd.get_context(),
      path_to='/my_prim_path',
      asset_path='C:/path/to/my_file.usd',
      instanceable=True)

Let me know if this helps!

1 Like

Perfect thanks!

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