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!
USD Primvar as a Parameter
576 4 0- ramonmascaros
- Member
- 3 posts
- Joined: 10月 2018
- Offline
- Heileif
- Member
- 127 posts
- Joined: 1月 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.
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 - 2024年3月16日 12:01:19
- ramonmascaros
- Member
- 3 posts
- Joined: 10月 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!
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!
- Heileif
- Member
- 127 posts
- Joined: 1月 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]
- ramonmascaros
- Member
- 3 posts
- Joined: 10月 2018
- Offline
-
- Quick Links