Hello,
I would like to create a custom selection tool for my HDA. My HDA takes in a bunch of curves and does some manipulations on them. I exposed a group parameter so users can select which curves are to be affected by this HDA.
The problem is the curves are all pretty close to one another and crisscrossing… they are hard to select.
The tool is designed so the incoming curves have a curveGroupId attribute to facilitate the selection. I know you can use any attribute to do your selection by pressing 9, but ideally, I would prefer to create a “select curve” button that calls a Python script to do these 3 things:
1 - Activate that selection mode by default (i.e. using the curveGroupId attribute for selection). Is there a script function that lets you activate and set the selection mode?
2 - To make the selection easier, I would like to temporarily convert the curves to polywires so the user can more easily select the right curve(s) he wants to edit. I'm guessing inside my HDA, I can wire up a polywire sop and plug it to a null that I name display_selection and I can force that node to display while the user is doing his curve selection !? How can my script force this display while I'm in selection mode?
3 - This one is a bit more tricky, but since a lot of curves are overlapping, even if I convert them to polywires, it can be very tricky to select a specific curve that's hidden behind a couple more curves. I'm wondering if we could implement some kind of functionality that raycast all curves/polywires on your mouse pointer and allows the user to use the mouse wheel or a keyboard shortcut to circle through the possible selections?
I know the 3rd one is a little more tricky to implement. If you only have answers for the first 2 points, then please share as just these two functionalities will do a world of difference for my HDA. But if you do happen to know how to do the 3rd functionality, that would be amazing if you can share any information on how to get that working as well. I'm guessing I have to implement my own selection viewer state to do something like that. I'm reading up on that right now, but while I'm wrapping my head around all this, any pointers would be appreciated.
Thanks.
Custom HDA group selection
6350 4 4-
- MathieuLeclaire
- Member
- 79 posts
- Joined: Feb. 2008
- Offline
-
- AlanZ
- Member
- 40 posts
- Joined: Feb. 2018
- Offline
Hi Mathieu,
1. I don't really know the answer to this one.. But since you are selecting from polywire dummies anyways, maybe you can convert the polywires into say polysoups, where prims with the same curveGroupId are put into the same soup. You can then convert this selection back to the curve selection using some VEX or Python.
2. If the user is to enter selection mode from an action button of a text field (or any other ways that call soputils.selectGroupParm()), you can add an (invisible) Operator Path parameter on your HDA, named e.g. ‘selection_op’, with a default value of ‘display_selection’. Then addbefore calling the soputils.selectGroupParm().
(You can also add a ‘nodepath’ entry to kwargs instead of ‘noderefparm’. These are documented in /Resources/houdini/python2.7libs/soputils.py.)
If, on the other hand, the user enters selection mode from the HDA's viewer state, you can probably use hou.Node.setOutputForViewFlag() [www.sidefx.com], which is what soputils uses. I've never tried it since I'm lazy and often leave the first output of my OTLs for display purpose only..
3. That sounds like an awesome design.. I don't know any HOM functions that returns all ray-geo intersections, but maybe you could:
Hope my answer could help.. Your HDA surely sounds interesting.
Alan
1. I don't really know the answer to this one.. But since you are selecting from polywire dummies anyways, maybe you can convert the polywires into say polysoups, where prims with the same curveGroupId are put into the same soup. You can then convert this selection back to the curve selection using some VEX or Python.
2. If the user is to enter selection mode from an action button of a text field (or any other ways that call soputils.selectGroupParm()), you can add an (invisible) Operator Path parameter on your HDA, named e.g. ‘selection_op’, with a default value of ‘display_selection’. Then add
kwargs['noderefparm'] = node.parm('selection_op')
(You can also add a ‘nodepath’ entry to kwargs instead of ‘noderefparm’. These are documented in /Resources/houdini/python2.7libs/soputils.py.)
If, on the other hand, the user enters selection mode from the HDA's viewer state, you can probably use hou.Node.setOutputForViewFlag() [www.sidefx.com], which is what soputils uses. I've never tried it since I'm lazy and often leave the first output of my OTLs for display purpose only..
3. That sounds like an awesome design.. I don't know any HOM functions that returns all ray-geo intersections, but maybe you could:
- In your viewer state code, read the pointing ray and write it to a parameter on your HDA node;
- Inside your HDA, use a helper wrangle or intersection analysis node that reads in the pointing ray and finds all intersections;
- Back in your viewer state code, read the intersected prims into a list;
- In onMouseWheelEvent(), cycle through the list, highlight the current value with a hou.GeometryDrawable [www.sidefx.com].
Hope my answer could help.. Your HDA surely sounds interesting.
Alan
-
- MathieuLeclaire
- Member
- 79 posts
- Joined: Feb. 2008
- Offline
-
- AlanZ
- Member
- 40 posts
- Joined: Feb. 2018
- Offline
-
- houdiniUsers
- Member
- 3 posts
- Joined: May 2020
- Offline
Hi Mathieu,
regarding your first question I've found the answer here: http://tomohirookita.blogspot.com/2022/06/action-buttonattribute.html [tomohirookita.blogspot.com]
To recap, you need to adjust the current scene viewer before starting the mesh selection:
All the best,
Dome
regarding your first question I've found the answer here: http://tomohirookita.blogspot.com/2022/06/action-buttonattribute.html [tomohirookita.blogspot.com]
To recap, you need to adjust the current scene viewer before starting the mesh selection:
import soputils #get current viewport p = hou.ui.paneTabOfType(hou.paneTabType.SceneViewer) #set group mask #set an attribute you need to use as a group p.setGroupListMask("@_test *") #enable group selection mode p.setGroupPicking(True) #show the list of the groups p.setGroupListVisible(True) #execute mesh selection kwargs['geometrytype'] = (hou.geometryType.Primitives,) kwargs['inputindex'] = 0 soputils.selectGroupParm(kwargs) #turinig off the group list p.setGroupListVisible(False)
All the best,
Dome
-
- Quick Links


