I'm trying to set a channel reference by entering a string in a set operation:
transformnode = hou.node('obj/track').createNode('xform', “transform” + str(minmaxspeedindexpoint))
transformnode.parm('px').set('ch(“../font' + str(x) + ‘/tx”)’)
but it's complaining that I can't set a numerical value to a non-numerical value.
how to set a channel reference in a Python script?
3325 3 1- dgirard
- Member
- 47 posts
- Joined: 7月 2014
- Offline
- malbrecht
- Member
- 806 posts
- Joined: 10月 2016
- Offline
Moin,
what's “x”? If it is undefined, it's definitely a non-numerical value (note that you are escaping from your quote in the parm().set() sequence, probably intentionally so).
One way to debug something like this is to set variables you use manually in a python shell (Houdini offers that conveniently) and step by step recreating the expression until you get the error. Then the last step/change you made is the culprit.
Marc
what's “x”? If it is undefined, it's definitely a non-numerical value (note that you are escaping from your quote in the parm().set() sequence, probably intentionally so).
One way to debug something like this is to set variables you use manually in a python shell (Houdini offers that conveniently) and step by step recreating the expression until you get the error. Then the last step/change you made is the culprit.
Marc
---
Out of here. Being called a dick after having supported Houdini users for years is over my paygrade.
I will work for money, but NOT for "you have to provide people with free products" Indie-artists.
Good bye.
https://www.marc-albrecht.de [www.marc-albrecht.de]
Out of here. Being called a dick after having supported Houdini users for years is over my paygrade.
I will work for money, but NOT for "you have to provide people with free products" Indie-artists.
Good bye.
https://www.marc-albrecht.de [www.marc-albrecht.de]
- tamte
- Member
- 8837 posts
- Joined: 7月 2007
- Offline
you nees to use .setExpression() instead of .set()
you can also use string formatting to build your strings
or the old string formatting, not sure whether that's being phased out or not, but for now may be shorter sometimes
transformnode = hou.node('obj/track').createNode('xform', "transform" + str(minmaxspeedindexpoint)) transformnode.parm('px').setExpression('ch("../font' + str(x) + '/tx")')
transformnode = hou.node('obj/track').createNode('xform', "transform{}".format(minmaxspeedindexpoint)) transformnode.parm('px').setExpression('ch("../font{}/tx")'.format(x))
transformnode = hou.node('obj/track').createNode('xform', "transform%d" % minmaxspeedindexpoint) transformnode.parm('px').setExpression('ch("../font%d/tx")' % x)
Edited by tamte - 2020年4月4日 18:58:56
Tomas Slancik
FX Supervisor
Method Studios, NY
FX Supervisor
Method Studios, NY
- dgirard
- Member
- 47 posts
- Joined: 7月 2014
- Offline
-
- Quick Links