How to get something like several array_nodes with arm.node_add_input?


#1

When using the arm.node_add_input inside a class for a new node, it adds those inputs after all others (using the array_nodes) and we can’t decide of this order.

Secondly, when we use the arm.node_remove_input, it destroys last NodeSockets and also those not created with arm.node_add_input (cleaning the array_nodes)

Is it possible to avoid this problem?
for example, giving us the possibility to separates NodeSockets into seperate array_nodes ?

( the code concerned is like this one

op = row.operator(‘arm.node_add_input’, text=‘New Hidden’, icon=‘PLUS’, emboss=True)
op.node_index = str(id(self))
op.socket_type = ‘NodeSocketInt’
op2 = row.operator(‘arm.node_remove_input’, text=’’, icon=‘X’, emboss=True)
op2.node_index = str(id(self))

)

(the code in arm_nodes.py concerned

class ArmNodeAddInputButton(bpy.types.Operator):
‘’‘Add new input’’’
bl_idname = ‘arm.node_add_input’
bl_label = ‘Add Input’
node_index = StringProperty(name=‘Node Index’, default=’’)
socket_type = StringProperty(name=‘Socket Type’, default=‘NodeSocketShader’)

def execute(self, context):
    global array_nodes
    inps = array_nodes[self.node_index].inputs
    inps.new(self.socket_type, 'Input ' + str(len(inps)))
    return{'FINISHED'}

class ArmNodeRemoveInputButton(bpy.types.Operator):
‘’‘Remove last input’’’
bl_idname = ‘arm.node_remove_input’
bl_label = ‘Remove Input’
node_index = StringProperty(name=‘Node Index’, default=’’)

def execute(self, context):
    global array_nodes
    node = array_nodes[self.node_index]
    inps = node.inputs
    min_inps = 0 if not hasattr(node, 'min_inputs') else node.min_inputs
    if len(inps) > min_inps:
        inps.remove(inps.values()[-1])
    return{'FINISHED'}

)