USD Primvar as a Parameter

   571   4   0
User Avatar
Member
3 posts
Joined: Oct. 2018
Offline
Hello,

Is there a way to use a primevar as a parameter? for example use "endTimeCode" from a camera as output of an usdRop, we cannot use "RenderFrame Range From Stage" because it's another branch.

Any suggestion?

Thanks!
User Avatar
Member
127 posts
Joined: Jan. 2015
Offline
Only way I know of to get a primvar is Python expression inside a parameter.

Example:
"
value = hou.pwd().inputs().stage().GetObjectAtPath("/cameras/camera1.horizontalApertureOffset").Get()
return value
"
If the value you want have timesamples the only way I have gotten it to work is to add frame number inside the "Get()".

Like this.
"
frame = hou.frame()
value = hou.pwd().inputs().stage().GetObjectAtPath("/cameras/camera1.horizontalApertureOffset").Get(frame)
return value
"
Forum removes the brackets with 0 inside after the "inputs()" for some reason, so you need to add that back inside the code.

But it sounds like you want metadata instead of primvars, that code is a little different. Can add metadata read code later when back infront of computer.

Edit:
"
hou.pwd().inputs().stage().GetMetadata("endTimeCode")
"

If you need customData from the Metadata this is one way to do it.
"
hou.pwd().inputs().stage().GetMetadata('customLayerData')
"

You will need to add brackets mentioned earlier for it to work.
Edited by Heileif - March 16, 2024 12:01:19
User Avatar
Member
3 posts
Joined: Oct. 2018
Offline
Thanks Heileif!

I don't know much of python, so I'm going to try what you said that for sure is the best. (I still don't get "Forum removes the brackets with 0 inside after the "inputs()" but i'll figure it out)
Meanwhile I have something in the middle.

· @time_end= usd_metadata(0,"/","endTimeCode"); in an attributeWrangle

and a edit properties node to get it

but always i need to update clicking on "set all parameter values from usd primitive"

Thanks!
User Avatar
Member
127 posts
Joined: Jan. 2015
Offline
ramonmascaros
Thanks Heileif!

I don't know much of python, so I'm going to try what you said that for sure is the best. (I still don't get "Forum removes the brackets with 0 inside after the "inputs()" but i'll figure it out)
Meanwhile I have something in the middle.

· @time_end= usd_metadata(0,"/","endTimeCode"); in an attributeWrangle

and a edit properties node to get it

but always i need to update clicking on "set all parameter values from usd primitive"

Thanks!

Did you get it to work?

You need the brackets with a 0 inside to get the first item in the Python list, because "hou.pwd().inputs().stage()" returns a list.
https://www.w3schools.com/python/python_lists.asp [www.w3schools.com]
User Avatar
Member
3 posts
Joined: Oct. 2018
Offline
now yes, thank you!
  • Quick Links