Search - User list
Full Version: HDA requires selecting faces from a group
Root » Houdini Engine for Maya » HDA requires selecting faces from a group
alfyou
I have a tool that takes a mesh as an input and also reveals a few group node (“Base Group”) fields for input.

However, I'm not sure what needs to go into the revealed group field for it to work. It only accepts meshes (which is fine), but it doesn't appear to actually use the data.

Can anyone explain to me how this works?
johnmather
Hi alfyou,

I'm not quite sure what you mean by “revealing” a few group nodes. Are you trying to provide your digital asset with a face selection from Maya?
alfyou
Hi John,

Apologies for not being clearer. I have a few group nodes (see attached) that require selection based on the geometry that I've set as the sub-network input.

How do I provide mesh or face selection into this field where it will properly utilize it?

(fields have been cleared in image)
johnmather
Hi alfyou, unfortunately the current method of specifying groups is less than ideal. You need to specify the component ids just like you would with the attribute ids inside of Houdini. Improving the UX of this shouldn't be difficult to implement, so I should be able to get to it by early next week.

In the mean-time, the easiest way to get these values is to select the components that you want to be part of the group, then run the following script in the Python script editor:

from maya import cmds

def get_selected_components(component_type):
    components = []
    sel_mask   = -1
    type_name  = ''
    
    if component_type.lower() == 'vtx':
        sel_mask = 31
        type_name = 'vertices'
    elif component_type.lower() == 'e':
        sel_mask = 32
        type_name = 'edges'
    elif component_type.lower() == 'f':
        sel_mask = 34
        type_name = 'faces'
    elif component_type.lower() == 'map':
        sel_mask = 35
        type_name = 'UVs'
    else:
        cmds.error('Unknown component type. Must be "vtx", "e", "f" or "map".')
    
    components_raw = cmds.filterExpand(cmds.ls(sl=True), sm=sel_mask, ex=False)
    
    if not components_raw:
        return None

    for component in components_raw:
        lidx = component.find('[') + 1
        ridx = component.rfind(']')
        
        if lidx <= 0 or ridx <= 0 or ridx <= lidx:
            cmds.warning('Could not determine %s index of "%s"' % (type_name, component))
        
        components.append(component[lidx:ridx].replace(':', '-'))
    
    return ', '.join(components)

def run_get_selected_components():
    print 'Selected components\n--------------------------------------------'
    print 'Vertices:', get_selected_components('vtx')
    print 'Edges:   ', get_selected_components('e')
    print 'Faces:   ', get_selected_components('f')
    print 'UVs:     ', get_selected_components('map')

run_get_selected_components()

This will print out the components that you need to specify in the group field in the digital asset. It will look something like the following:
Selected components
--------------------------------------------
Vertices: 1860-1866, 1912-1914
Edges: None
Faces: None
UVs: None
alfyou
Hi John,

Ah! Ok I get it now. Thank you for the script and clarification on the use of component IDs! I'll add this to our toolset in the meantime.
johnmather
Hi Alfyou,

This has been implemented, and will be available in tomorrow's builds - 18.0.430 and 17.5.581.

More information can be found here: https://www.sidefx.com/forum/topic/72894/?page=1#post-308341 [www.sidefx.com]
alfyou
johnmather
Hi Alfyou,

This has been implemented, and will be available in tomorrow's builds - 18.0.430 and 17.5.581.

More information can be found here: https://www.sidefx.com/forum/topic/72894/?page=1#post-308341 [www.sidefx.com]

Totally missed this. Thank you!!

EDIT: BTW this is soooooo satisfying to use….
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB