Evaluate in Python from a path ?
4156 6 1- _Christopher_
- Member
- 767 posts
- Joined: 4月 2014
- Offline
- quentinC
- Member
- 49 posts
- Joined: 9月 2017
- Offline
- _Christopher_
- Member
- 767 posts
- Joined: 4月 2014
- Offline
- goldfarb
- スタッフ
- 3462 posts
- Joined: 7月 2005
- Offline
- _Christopher_
- Member
- 767 posts
- Joined: 4月 2014
- Offline
- quentinC
- Member
- 49 posts
- Joined: 9月 2017
- Offline
python doesn't understand where you are in the same way hscript does. As arctor said, you need to run eval() on the node as a python object.
The function my_node = hou.node(“/obj/path_to_node”) will return the node as a python object and store it as my_node. You can then call my_node.parm(“tx”).eval() to get the tx parameter value of this node. This is all in arctors post.
The function my_node = hou.node(“/obj/path_to_node”) will return the node as a python object and store it as my_node. You can then call my_node.parm(“tx”).eval() to get the tx parameter value of this node. This is all in arctors post.
- NFX
- Member
- 183 posts
- Joined: 12月 2011
- Offline
It's true that if you run the code in the shell, python won't know what node you're talking about without you passing it specifically. However, if you run code as a python expression on the node itself then you can access the parameter that called the function with hou.evaluatingParm(). Once you have that parameter you can backtrack to the node and get the ‘tx’ parameter you want.
node = hou.evaluatingParm().node()
parm = node.parm('tx')
Again this will not work in the shell, only when executing code on the node itself.
node = hou.evaluatingParm().node()
parm = node.parm('tx')
Again this will not work in the shell, only when executing code on the node itself.
-
- Quick Links