Update USD file on Nucleus server with python script

Hi,

I want to use a python script to update an USD file stored on Nucleus Server. When I do it locally, I use

from pxr import Usd, UsdGeom
stage: Usd.Stage = Usd.Stage.Open("C:/Omniverse/Assets/MyAsset.usd")
…

How can I change this with a Nucleus Server URL ?

Using Kit, which has Client Library, you should just be able to pass in a the omniverse:// url in the same way. But you would need our Client Library and USD Resolver. From within Kit it would look like this.

from pxr import Usd, UsdGeom

stage = Usd.Stage.Open("omniverse://localhost/Projects/path/test.usd")

print(stage.GetDefaultPrim())

Omniverse Client Library — Omniverse Client Library 2.60.1 documentation

If you want a simple example of reading data from Nucleus with Client Library, it would look like this

def omni_read_to_bytes(omniverse_url:str) -> omni.client.Result|bytes:
    omni_data = omni.client.read_file(omniverse_url)
    if omni_data[0] != omni.client.Result.OK:
        return omni_data[0]
    return memoryview(omni_data[-1]).tobytes()
2 Likes

Great, thanks Daniel !

1 Like

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