python - refer to selected node.

   18188   5   0
User Avatar
Member
122 posts
Joined: May 2006
Offline
Hi, how can i refer to selected node using python without typing path? in Nuke, i can use :
nuke.selectedNode() or nuke.selectedNodes()
but in houdini that doens't work , i tried hou.selectedNode() and no luck. Anyone can help?

second question : when using python in parameter expression, how can i refer to current node. Ussually i can use hou.node(“.”), i'm just curious is there any other way to do it? again in nuke , i can use nuke.thisNode() . I tried couple of ways : hou.thisNode() or hou.node(this) or hou.node(self) and got error .

thanx
User Avatar
Member
875 posts
Joined: Oct. 2008
Offline
From the top of my head I don't know about the selected node, but the current one should be hou.pwd() I think.
--
Jobless
User Avatar
Member
122 posts
Joined: May 2006
Offline
Soothsayer
From the top of my head I don't know about the selected node, but the current one should be hou.pwd() I think.

hou.pwd() doesn't work. The selected node means the node which i select in network view. If i select any node in network viewer, the pwd() has no relationship with the selected one.

thanx for reply.
User Avatar
Member
326 posts
Joined: May 2007
Offline
maybe what you need is :
hou.selectedNodes()
https://vimeo.com/user3971456/videos [vimeo.com]
User Avatar
Member
1926 posts
Joined: Nov. 2006
Offline
hou.selectedNodes() is the correct way to access any nodes that are currently selected in Houdini.

hou.pwd() is the correct way to access the node a parameter belongs to when you are inside a parameter. hou.pwd() is only really useful inside of parameters, cooking Python operators or digital asset callbacks/menu scripts. Unless you specifically set the current working dir using hou.setPwd() then usually it will point to /.

If these are not working correctly for you please post a hip file detailing your problem and we'll do our best to help you out.
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
122 posts
Joined: May 2006
Offline
Silly …. i didn't try with (s) … Yes, hou.selectedNodes() is the correct one, i only tried hou.selectedNode() without the ‘s’ which i hope will return only single selected obj not tuple.

Thanx a lot guyz.
  • Quick Links