MultiParm Block list - return the attribute menu script

   514   1   0
User Avatar
Member
11 posts
Joined: March 2017
Offline
How can I achieve functionality similar to "Attribute Swap", where the dropdown menu returns the corresponding data types based on the attribute type?
To ensure that your script handles multiple class parameters without overwriting each other and executes correctly, you need to accumulate the results for each class parameter and avoid reassigning the result list. Here's an updated script that ensures the attributes for each class are correctly added to the final result:

r = []
node = kwargs['node']
inputs = node.inputs()
number_casts = node.evalParm("number_casts")
if inputs and inputs[0]:

    geo = inputs[0].geometry()
    
    if geo:
        

#遍历每个属性类别
        for i in range(1, number_casts + 1):
            c = node.parm('class'+str(i)).evalAsString()
        
            if c == 'detail':
                attrs = geo.globalAttribs()
            elif c == 'primitive':
                attrs = geo.primAttribs()
            elif c == 'point':
                attrs = geo.pointAttribs()
            else: # vertex
                attrs = geo.vertexAttribs()
        for a in attrs:
            r.extend([a.name(), a.name()])
return r
Is there anyone who can help guide me? Thank you very much

Attachments:
QQ图片20240622215857.png (88.0 KB)
QQ图片20240622220044.png (76.3 KB)

User Avatar
Member
8839 posts
Joined: July 2007
Online
To avoid reinventing the wheel you can maybe use hou.SopNode.generateInputAttribMenu() [www.sidefx.com]

Or hou.Geometry.generateAttribMenu() [www.sidefx.com]
Tomas Slancik
FX Supervisor
Method Studios, NY
  • Quick Links