Skip to content

Commit

Permalink
Update loop_in.py (#3762)
Browse files Browse the repository at this point in the history
  • Loading branch information
vicdoval authored Dec 8, 2020
1 parent b132edc commit d1c03e0
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions nodes/logic/loop_in.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from bpy.props import IntProperty, EnumProperty, BoolProperty

from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import updateNode, enum_item_4, list_match_func, numpy_list_match_modes
from sverchok.data_structure import updateNode, enum_item_4, numpy_list_match_modes
from sverchok.utils.sv_node_utils import frame_adjust

class SvCreateLoopOut(bpy.types.Operator):
Expand Down Expand Up @@ -90,11 +90,11 @@ def update_max_iterations(self, context):
def update_mode(self, context):
self.inputs['Iterations'].hide_safe = self.mode == "For_Each"
if self.mode == "For_Each":
self.outputs[1].label ='Item Number'
self.outputs[2].label ='Total Items'
self.outputs[1].label = 'Item Number'
self.outputs[2].label = 'Total Items'
else:
self.outputs[1].label ='Loop Number'
self.outputs[2].label ='Total Loops'
self.outputs[1].label = 'Loop Number'
self.outputs[2].label = 'Total Loops'
updateNode(self, context)

mode: EnumProperty(
Expand All @@ -118,10 +118,11 @@ def sv_init(self, context):
self.outputs.new('SvStringsSocket', 'Loop Number')
self.outputs.new('SvStringsSocket', 'Total Loops')

def draw_buttons(self,ctx, layout):
def draw_buttons(self, ctx, layout):
if not self.linked_to_loop_out:
layout.operator("node.create_loop_out", icon='CON_FOLLOWPATH', text="Create Loop Out")
layout.prop(self, 'mode', expand=True)

def draw_buttons_ext(self, ctx, layout):
layout.prop(self, 'mode', expand=True)
if self.mode == "Range":
Expand Down Expand Up @@ -154,21 +155,18 @@ def sv_update(self):
while len(self.inputs) > 2 and not self.inputs[-2].links:
self.inputs.remove(self.inputs[-1])
self.outputs.remove(self.outputs[-1])
# check number of connections and type match input socket n with output socket n
count_inputs = 0
count_outputs = 0
# match input socket n with output socket n
for idx, socket in enumerate(self.inputs[1:]):
if socket.name in self.outputs and self.outputs[socket.name].links:
count_outputs += 1

if socket.links:
count_inputs += 1

if type(socket.links[0].from_socket) != type(self.outputs[socket.name]):
self.outputs.remove(self.outputs[socket.name])
self.outputs.new(socket.links[0].from_socket.bl_idname, socket.name)
self.outputs.move(len(self.outputs)-1, idx+3)
for inp, outp in zip(self.inputs[1:], self.outputs[3:]):
outp.label = inp.label
if self.outputs[0].is_linked and self.outputs[0].links[0].to_socket.node.bl_idname=='SvLoopOutNode':
if self.outputs[0].is_linked and self.outputs[0].links[0].to_socket.node.bl_idname == 'SvLoopOutNode':
self.linked_to_loop_out = True
else:
self.linked_to_loop_out = False
Expand Down

0 comments on commit d1c03e0

Please sign in to comment.