Skip to content

Commit

Permalink
fix #5049. Logic Functions cannot recreate node
Browse files Browse the repository at this point in the history
  • Loading branch information
satabol committed Nov 5, 2023
1 parent 3f3e65a commit 1975db7
Showing 1 changed file with 41 additions and 7 deletions.
48 changes: 41 additions & 7 deletions nodes/logic/logic_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,47 @@ def rclick_menu(self, context, layout):
layout.prop(self, "output_numpy", expand=False)

def migrate_from(self, old_node):
self.function_name = old_node.items_
self.inputs['A'].default_int_property = old_node.x
self.inputs['B'].default_int_property = old_node.y
self.inputs['A'].default_float_property = old_node.i_x
self.inputs['B'].default_float_property = old_node.i_y
self.inputs['A'].default_property_type = 'float' if old_node.prop_types[0] else 'int'
self.inputs['B'].default_property_type = 'float' if old_node.prop_types[1] else 'int'
old_node_input_A = None
if 'A' in old_node.inputs:
old_node_input_A = old_node.inputs['A']
old_node_input_B = None
if 'B' in old_node.inputs:
old_node_input_B = old_node.inputs['B']
if hasattr(old_node, 'items_'):
self.function_name = old_node.items_
if hasattr(old_node, 'x'):
self.inputs['A'].default_int_property = old_node.x
elif old_node_input_A and hasattr(old_node_input_A, 'default_int_property'):
self.inputs['A'].default_int_property = old_node_input_A.default_int_property

if hasattr(old_node, 'y'):
self.inputs['B'].default_int_property = old_node.y
elif old_node_input_B and hasattr(old_node_input_B, 'default_int_property'):
self.inputs['B'].default_int_property = old_node_input_B.default_int_property

if hasattr(old_node, 'i_x'):
self.inputs['A'].default_float_property = old_node.i_x
elif old_node_input_A and hasattr(old_node_input_A, 'default_float_property'):
self.inputs['A'].default_float_property = old_node_input_A.default_float_property

if hasattr(old_node, 'i_y'):
self.inputs['B'].default_float_property = old_node.i_y
elif old_node_input_B and hasattr(old_node_input_B, 'default_float_property'):
self.inputs['B'].default_float_property = old_node_input_B.default_float_property

if hasattr(old_node, 'prop_types') and len(old_node.prop_types)>0:
self.inputs['A'].default_property_type = 'float' if old_node.prop_types[0] else 'int'
elif old_node_input_A and hasattr(old_node_input_A, 'default_property_type'):
self.inputs['A'].default_property_type = old_node_input_A.default_property_type
self.inputs['A'].use_prop = True # like sv_init
self.inputs['A'].show_property_type = True

if hasattr(old_node, 'prop_types') and len(old_node.prop_types)>1:
self.inputs['B'].default_property_type = 'float' if old_node.prop_types[1] else 'int'
elif old_node_input_B and hasattr(old_node_input_B, 'default_property_type'):
self.inputs['B'].default_property_type = old_node_input_B.default_property_type
self.inputs['B'].use_prop = True # like sv_init
self.inputs['B'].show_property_type = True

def sv_init(self, context):
a = self.inputs.new('SvStringsSocket', 'A')
Expand Down

0 comments on commit 1975db7

Please sign in to comment.