Case #3: Search Asset Database with USD Search and Write Python with USD Code API#

Scenario#

While setting up a new facility digital twin to train robotic systems, a developer must find and place many different objects which exist in the real facility. USD Search API makes it possible for the developer to ask an API to find the desired assets. USD Code API can help the developer write some of the python faster to modify the USD stage. In this example, we will develop a simple utility to find and place large storage racks in an open space leveraging both NIMs.

Steps#

  1. Enable the Sample Browser by navigating to Window > Browsers > Examples.

  2. In the Examples folder, double-click Warehouse to open it.

    Note

    Opening the stage will download assets and shaders. It may take a moment to load.

    Warehouse scene sample browser example
  3. Open the USD Code API extension. Click New Chat and select USD Search from the node dropdown.

  4. Enter the prompt Large Storage Racks in the prompt window. Press the Execute Code icon.

    USD Search API prompt for asset discovery
  5. Click and drag one of the result assets to add it to your scene.

    USD Search results showing storage rack assets
  6. View the asset in your scene to determine if it is a good fit.

    Storage rack asset preview in scene viewport
  7. Right click the payload in the Stage panel and select Copy Prim Path.

    Prim path copy from stage panel context menu
  8. Open the USD Code API extension, click New Chat, and select USD Code Interactive from the node dropdown.

    New chat dialog for USD Code Interactive
  9. Prompt USD Code Interactive with the following:

    duplicate the prim <copied prim name> 3 times and offset them 2m on the x axis
    starting from the prim's position``. Click the ``Execute Code`` icon.
    Try various methods for duplicating the prim. For example, with the prim
    selected you can prompt: ``duplicate the selected prim 3 times...``.
    
    USD Code Interactive prim duplication result

    Note

    If the selected assets are coming in at the wrong scale, feel free to fix the scale in a prompt or manually scale them (.01,.01,.01).

  10. You’ve successfully added your shelves to your scene and placed them in the environment! You can utilize the same method with different assets to populate the rest of your warehouse.