channel reference with python

   16091   8   4
User Avatar
Member
624 posts
Joined: Aug. 2008
Offline
is it possible using Python to do
right click,
copy parameter, and
do any of the following
paste copied values
paste copied expressions
then set that as paste copied relative reference
and so on?

or do i manually have to do a string, with
`ch(“……./…/”)

thanks guys.
User Avatar
Member
1926 posts
Joined: Nov. 2006
Offline
You can set hou.Parm objects to be other hou.Parm objects, thereby giving you the reference automatically.
>>> p1 = hou.parmTuple('/obj/null1/t')
>>> p2 = hou.parmTuple('/obj/null2/t')
>>> p1.set(p2)
>>> p1.expression()
'ch(“../null2/tx”)'
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
145 posts
Joined: Feb. 2012
Offline
This isnt exactly the same as described in the top post as now the parm shares the same object (change either and both change) rather than just one parm referencing the others value.
Any way to do this so it has the exact functionality of the paste references in the right click menu?
I have found using parm.set('`chs“/out/mantra/vm_picture”`') dosent work that well if there is already a value in the parm.. seems to set the string but not the expression, but there is no expression in there???… dont really understand.
User Avatar
Member
624 posts
Joined: Aug. 2008
Offline
awesome and painless way to set the channels

thanks for the tip.
User Avatar
Member
8081 posts
Joined: July 2005
Offline
JordanWalsh
This isnt exactly the same as described in the top post as now the parm shares the same object (change either and both change) rather than just one parm referencing the others value.

I'm pretty sure you would get exactly the same behaviour as if you made the channel reference expression manually.
User Avatar
Member
624 posts
Joined: Aug. 2008
Offline
graham this should also work with tuples?

if i want to set the 3 parms at the same time? i get an error:
TypeError: Cannot set ramp on a non-ramp parm

is it the hou.parmTuple doesn't have that same behavior?

thanks
User Avatar
Member
1926 posts
Joined: Nov. 2006
Offline
No, unfortunately parm tuples don't support this. You can write a simple function that will do this using iteration since when you iterate over a parm tuple it gives you the hou.Parm objects.
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
3 posts
Joined: Oct. 2013
Offline
JordanWalsh is right. It's not the same. I just tried using the method described by graham and in addition to making the connection as desired it also created a channel reference in p2 back to itself. Which as you can imagine is causing a few issues.

Just thought you'd like to know.

PS. Running v12.5.427
User Avatar
Member
1 posts
Joined: Oct. 2018
Offline
you don't need to add key ` (left quote)
you just set
ch(“……./…/”)
not
`ch(“……./…/”)`
  • Quick Links