Create a reference of a primitive from multiple usd files? [PY, USD] SOLVED +hip

   469   7   1
User Avatar
Member
60 posts
Joined: Nov. 2019
Offline
Hello!

I am trying a few things but not succeeding through the documentation. What is the way to create in a Python LOP a Reference of a primitive form a usd file in disk?

The same thing with nodes is done using a Reference lop and referencing the primitive through the multi-input from a usd coming through a sublayer.

Thanks
Edited by Cicuta - May 13, 2024 15:15:03
User Avatar
Member
60 posts
Joined: Nov. 2019
Offline
It can also be done quite easily (and efficiently) via Inline USD lop, but I am curious about the python method.
Edited by Cicuta - May 9, 2024 09:26:22
User Avatar
Member
140 posts
Joined: Nov. 2016
Offline
Hi!

Here you can see some examples from Omniverse website:

https://docs.omniverse.nvidia.com/dev-guide/latest/programmer_ref/usd/references-payloads/add-reference.html [docs.omniverse.nvidia.com]

Hope that helps,

Cheers!
User Avatar
Member
60 posts
Joined: Nov. 2019
Offline
Cicuta
https://docs.omniverse.nvidia.com/dev-guide/latest/programmer_ref/usd/references-payloads/add-reference.html [docs.omniverse.nvidia.com]

I was using that as my main reference but I was missing one thing and wasn't getting what I expected. I managed to make it work now. Thanks though!
As soon as I find a moment I will post a hip file with the 3 different methods in case it can be of any help to anyone.
Edited by Cicuta - May 9, 2024 11:55:22
User Avatar
Member
60 posts
Joined: Nov. 2019
Offline
Reading the AddReference() documentation it doesn't look like you can add multiple references within it. It would require using a loop containing the function right?
User Avatar
Member
140 posts
Joined: Nov. 2016
Offline
Yes, AFAIK if you want to add multiple references you will need to do it with a loop because the AddReference() is expecting individual reference path and a primpath.
User Avatar
Member
60 posts
Joined: Nov. 2019
Offline
Hi! Here is the file with the 3 mentioned examples if it can be of use to anyone. Each will be useful for different scenarios. In my case, since its part of a larger logic driven by some python in an HDA module, both the InlineUSD and pythonscript lop are the better options. For what I want to do, I feel like the best one is the InlineUSD method.

Cheers!

Attachments:
references_from_multiple_files.hip (439.6 KB)

User Avatar
Member
140 posts
Joined: Nov. 2016
Offline
It has some interesting solutions, thanks for sharing it
  • Quick Links