1
$\begingroup$

I'm trying to make a modifier list and for the Geometry nodes modifier, I cannot find a way to access the Socket name I have in my group input node.

enter image description here

I'm currently using this code.

for key in modifier.keys():
    if key.startswith('Socket') and not ('attribute_name' in key or 'use_attribute' in key):
        row = col.row(align=True)
        row.prop(modifier, f'["{key}"]')

Do you have any idea?

Thank you for your help.

$\endgroup$
4

1 Answer 1

1
$\begingroup$

Thank you for your help guys this is the code to make it work.

obj = context.object
    gnmod = None
    for gnmod in obj.modifiers:
        if gnmod.type == "NODES":
            break

    # Create a dictionary to map socket identifiers to their names
    socket_names = {f"{item.identifier}_attribute_name": item.name for item in gnmod.node_group.interface.items_tree if item.in_out == "INPUT"}

    for key in modifier.keys():
        if key.startswith('Socket') and not ('_attribute_name' in key or 'use_attribute' in key):
            socket_id = key.split('_')[1]
            attr_name_key = f"Socket_{socket_id}_attribute_name"
            if attr_name_key in socket_names:
                row = col.row(align=True)
                row.prop(modifier, f'["{key}"]', text=socket_names[attr_name_key])

enter image description here

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .