Adding a selector to an HDA

   952   3   2
User Avatar
Member
11 posts
Joined: Nov. 2016
Offline
Hi, what is the best way to add a selector to an HDA? By selector I mean a prompt asking for a geometry selection. I tried to figure this out by looking at `matchsize` HDA but I can't find a part responsible for the selection. Second thing I tried was Tool Scripts recommended by State Selectors [www.sidefx.com] but the examples do not fully work. Tool Script example for a filter node shows the prompt but fails to fill the group parameter ( I think createFilterSop may be bugged ). Any tips would be great.
User Avatar
Member
42 posts
Joined: March 2019
Offline
Hi, don't know if its what you're looking for, but you can use a group Node and promote the Basegroup Selection Parameter to get a geometry selection.

Edited by Lucca - May 23, 2022 07:02:46

Attachments:
Screenshot 2022-05-23 122751.png (19.9 KB)

User Avatar
Member
11 posts
Joined: Nov. 2016
Offline
Hi, thanks but that's not what I had in mind. When you click some shelf tools they will check if you have anything selected and if not they will prompt you to select what they need. It usually looks like this:



You can see that the text is customized for matchsize. I'd like to know how this is done.

Attachments:
selector.PNG (36.2 KB)

User Avatar
Member
11 posts
Joined: Nov. 2016
Offline
I'm still not sure how to mimic something like matchsize but code below does most of it. It's the same thing polybevel does.
The issue is it will throw an error if user doesn't select anything. More suggestions are welcome, thanks

import soptoolutils

soptoolutils.addNodeWithCurrentSelection(
    kwargs, '$HDA_NAME', 
    allowed_group_types = { 'prims' },
    group_parm = 'base_group_name',
    empty_means_all = False,
    default_group_type = 'prims',
    asterisk_to_select_all = True)
  • Quick Links