Hi,
I ran into a problem with using Python setExpression() function to reference a string channel.
For float and integer parameters it works fine. However, only the string parameter couldn't work.
Here are the examples I did.
First attempt:
dens_newname.parm('frompt0').setExpression('chs("../custom_density")', language=hou.exprLanguage.Hscript)
Second time I copy and paste the parameter as a relative reference, then I copy `chs("../custom_density")`
dens_newname.parm('frompt0').setExpression('`chs("../custom_density")`', language=hou.exprLanguage.Hscript)
None of them work.
If anyone has a solution for this, please let me know.
How to use Python to set expression to reference a channel
2883 3 2- Harold1007
- Member
- 4 posts
- Joined: March 2019
- Offline
- krueger
- Member
- 191 posts
- Joined: Oct. 2018
- Offline
- Harold1007
- Member
- 4 posts
- Joined: March 2019
- Offline
mkps
What's not working? The first one looks correct, but you could try without the language argument because it will default to hscript anyway.
You can also try your last attempt just using set() instead of setExpression() ie:dens_newname.parm('frompt0').set('`chs("../custom_density")`')
Thanks for replying.
I end up using set() instead of setExpression(), and it got to work. I didn't really know the reason why setExpression() couldn't work.
- 99463816
- Member
- 1 posts
- Joined: Nov. 2017
- Offline
-
- Quick Links