from lnx.logicnode.lnx_nodes import * class ArrayAddNode(LnxLogicTreeNode): """Adds the given value to the given array. @input Array: the array to manipulate. @input Modify Original: if `false`, the input array is copied before adding the value. @input Unique Values: if `true`, values may occur only once in that array (only primitive data types are supported). """ bl_idname = 'LNArrayAddNode' bl_label = 'Array Add' lnx_version = 5 min_inputs = 6 def __init__(self): super(ArrayAddNode, self).__init__() array_nodes[self.get_id_str()] = self def lnx_init(self, context): self.add_input('LnxNodeSocketAction', 'In') self.add_input('LnxNodeSocketArray', 'Array') self.add_input('LnxBoolSocket', 'Modify Original', default_value=True) self.add_input('LnxBoolSocket', 'Unique Values') self.add_input('LnxBoolSocket', 'Add First') self.add_input('LnxDynamicSocket', 'Value') self.add_output('LnxNodeSocketAction', 'Out') self.add_output('LnxNodeSocketArray', 'Array') def draw_buttons(self, context, layout): row = layout.row(align=True) op = row.operator('lnx.node_add_input_value', text='Add Input', icon='PLUS', emboss=True) op.node_index = self.get_id_str() op.socket_type = 'LnxDynamicSocket' column = row.column(align=True) op = column.operator('lnx.node_remove_input', text='', icon='X', emboss=True) op.node_index = self.get_id_str() if len(self.inputs) == self.min_inputs: column.enabled = False def get_replacement_node(self, node_tree: bpy.types.NodeTree): if self.lnx_version not in (0, 4): raise LookupError() return NodeReplacement.Identity(self)