Successfully load the USD file using the USD Composer’s “File” menu.
However, when trying to load the same file using the API, it doesn’t work.
import omni.usd
usd_file_path = r"C:\Users\uname\Downloads\scene.usd"
stage = omni.usd.get_context().get_stage()
stage.Load(usd_file_path)
from pxr import Usd
usd_file_path = r"C:\Users\uname\Downloads\scene.usd"
stage = Usd.Stage.Open(usd_file_path)
Console Log
2024-09-21 20:22:36 [3,233,094ms] [Warning] [omni.usd] Warning: in SdfPath at line 81 of C:\g\97199581\USD\pxr\usd\sdf\path.cpp – Ill-formed SdfPath <C:\Users\uname\Downloads\scene.usd>: syntax error
Any support/suggestion much appreciated!
Hi @abhishek.chitwar
Welcome to the Forums :)
You will want to structure your file path without the r and add double backslashes.
Example:
from pxr import Usd
usd_file_path = "C:\\Users\\uname\\Downloads\\scene.usd"
Usd.Stage.Open(usd_file_path)
Let me know if this resolves your issue!
2 Likes
Hi AshleyG_NVIDIA,
There is still an issue with the solution provided. I am not sure why it’s not working as expected.
I managed to make it work using following method:
usd_file_path = r"C:\Users\uname\Downloads\scene.usd"
context = omni.usd.get_context()
context.open_stage(usd_file_path)
Please let me know your views.
Thanks!
Abhishek
Hi there,
Sorry you are having issues. I am not really understanding where the “r” comes from. That should not be required. Are you reading that somewhere in our docs ?
Hi Richard!
I am just passing path as raw string. Since it’s not able to recognize the path, or I need to escape it “\” to get recognize. Since it’s got failed, I tried this and it worked.
Well good, as long as it works for you. Great !
1 Like