Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix can not get total when convert it to input on loops nodes #352

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions py/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,14 +685,15 @@ def __init__(self):
def INPUT_TYPES(cls):
return {
"required": {
"total": ("INT", {"default": 1, "min": 0, "max": 100000, "step": 1}),
"total": ("INT", {"default": 1, "min": 1, "max": 100000, "step": 1}),
},
"optional": {
"initial_value%d" % i: (AlwaysEqualProxy("*"),) for i in range(1, MAX_FLOW_NUM)
},
"hidden": {
"initial_value0": (AlwaysEqualProxy("*"),),
"prompt": "PROMPT",
"extra_pnginfo": "EXTRA_PNGINFO",
"unique_id": "UNIQUE_ID"
}
}
Expand All @@ -703,9 +704,13 @@ def INPUT_TYPES(cls):

CATEGORY = "EasyUse/Logic/For Loop"

def for_loop_start(self, total, prompt=None, unique_id=None, **kwargs):
def for_loop_start(self, total, prompt=None, extra_pnginfo=None, unique_id=None, **kwargs):
graph = GraphBuilder()
i = 0
unique_id = unique_id.split('.')[len(unique_id.split('.'))-1] if "." in unique_id else unique_id
node = next((x for x in extra_pnginfo['workflow']['nodes'] if x['id'] == int(unique_id)), None)
if node:
node['properties']['total'] = total
if "initial_value0" in kwargs:
i = kwargs["initial_value0"]
initial_values = {("initial_value%d" % num): kwargs.get("initial_value%d" % num, None) for num in range(1, MAX_FLOW_NUM)}
Expand Down Expand Up @@ -744,7 +749,11 @@ def for_loop_end(self, flow, prompt=None, extra_pnginfo=None, my_unique_id=None,
total = None
if extra_pnginfo:
node = next((x for x in extra_pnginfo['workflow']['nodes'] if x['id'] == int(while_open)), None)
total = node['widgets_values'][0] if "widgets_values" in node else None
if node:
if 'properties' in node and 'total' in node['properties']:
total = node['properties']['total']
else:
total = node['widgets_values'][0] if "widgets_values" in node else None
if total is None:
raise Exception("Unable to get parameters for the start of the loop")
sub = graph.node("easy mathInt", operation="add", a=[while_open, 1], b=1)
Expand Down
1 change: 1 addition & 0 deletions web_version/v2/assets/extensions-DK7x7jQd.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion web_version/v2/assets/extensions-DjHfjjgA.js

This file was deleted.

2 changes: 1 addition & 1 deletion web_version/v2/easyuse.js

Large diffs are not rendered by default.