Is there a python function equivalent to the deselectWorkItem()method?
I can't seem to find anything in the docs that might indicate how to get a work item selected without having to manually select it.
I have a top network that outputs a single work item from a Filter by Range node run through an external parm reference.
I can also with python get that Top Nework to output the single work item with pythons cookWorkItems() method.
But can't seem to automate the last step of selecting that work item.
I was thinking of submitting an RFE...but thought I would ask here in case there might already be a python method/function for this that I am unaware of.
Python deselectWorkItem() equivalent for selecting
751 3 0-
- BabaJ
- Member
- 2137 posts
- Joined: Sept. 2015
- Offline
-
- tpetrick
- Staff
- 607 posts
- Joined: May 2014
- Offline
You can select a work item using hou.TopNode.setSelectedWorkItem(), as described bere: https://www.sidefx.com/docs/houdini/hom/hou/TopNode.html#setSelectedWorkItem [www.sidefx.com]
You'll need to pass in the unique ID of the work item -- not the index of the work item in the node. A work item's ID can be retrieved using it's ID property, e.g. pdg.WorkItem.id.
You'll need to pass in the unique ID of the work item -- not the index of the work item in the node. A work item's ID can be retrieved using it's ID property, e.g. pdg.WorkItem.id.
-
- BabaJ
- Member
- 2137 posts
- Joined: Sept. 2015
- Offline
Thanks tpetrick.
Indeed that was 'method' I was looking for (setSelectedWorkItem()).
However, it's a catch 22 to be able to use it.
I have multiple Top Networks, that get accessed outside the Top Networks themselves.
So I created unique attribute names for each Network, e.g. TopNetwork_Name > @pdg_id
I have buttons with callback scripts(On the red null nodes in the example file) that run the python functions in the Python Source Editor.
For testing purposes I split it up into two buttons. The first button(Set Wedge) cooks and outputs the desired work item.
The second button(Set Work Item) I used the setSelectedWorkItem() method to try and select the work item.
However, unless the work item is manually selected, that ID number needed by the method is not available.
Hence the catch 22.
The ID number is actually there when I middle mouse on the work item(but not selecting it) - as I can make note of the number, manually enter that number in the python function and run it - Then it will work.
But that attribute I create of the pdg_id is not available until the work item is selected, so that attribute cannot be passed to the function which in turn does not allow me to use the button(which calls the function) to set the work item as selected.
I've included a scaled down version of my project. The red null nodes is where the button and callback functions reside.
Indeed that was 'method' I was looking for (setSelectedWorkItem()).
However, it's a catch 22 to be able to use it.
I have multiple Top Networks, that get accessed outside the Top Networks themselves.
So I created unique attribute names for each Network, e.g. TopNetwork_Name > @pdg_id
I have buttons with callback scripts(On the red null nodes in the example file) that run the python functions in the Python Source Editor.
For testing purposes I split it up into two buttons. The first button(Set Wedge) cooks and outputs the desired work item.
The second button(Set Work Item) I used the setSelectedWorkItem() method to try and select the work item.
However, unless the work item is manually selected, that ID number needed by the method is not available.
Hence the catch 22.
The ID number is actually there when I middle mouse on the work item(but not selecting it) - as I can make note of the number, manually enter that number in the python function and run it - Then it will work.
But that attribute I create of the pdg_id is not available until the work item is selected, so that attribute cannot be passed to the function which in turn does not allow me to use the button(which calls the function) to set the work item as selected.
I've included a scaled down version of my project. The red null nodes is where the button and callback functions reside.
Edited by BabaJ - Jan. 16, 2025 11:54:39
-
- tpetrick
- Staff
- 607 posts
- Joined: May 2014
- Offline
You'll have to have some way to know which work item to actually select. If necessary, you can search through the list of work items in the node and check to see if a given work item is the one you want, and then select it by ID. For example, to select a work item by it's frame value:
The underlying PDG node returned from the TOP node has a property called workItems that contains all of the work items in that node: https://www.sidefx.com/docs/houdini/tops/pdg/Node.html [www.sidefx.com]
There isn't a method to get all work items in the whole graph since it would difficult to provide a thread safe implementation.
def selectByIndex(top_node, frame): pdg_node = top_node.getPDGNode() for work_item in pdg_node.workItems: if work_item.frame == frame: top_node.setSelectedWorkItem(work_item.id) break
The underlying PDG node returned from the TOP node has a property called workItems that contains all of the work items in that node: https://www.sidefx.com/docs/houdini/tops/pdg/Node.html [www.sidefx.com]
There isn't a method to get all work items in the whole graph since it would difficult to provide a thread safe implementation.
-
- Quick Links