Skip to content

Commit

Permalink
CAP-FIX: real fix for the indexing, to be cleaned
Browse files Browse the repository at this point in the history
  • Loading branch information
9and3 committed Jan 28, 2024
1 parent 5e70cb8 commit 2b34eba
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
36 changes: 21 additions & 15 deletions GH/PyGH/scriptsyncGH_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def __str__(self):
class ScriptSyncCPy(component):
def __init__(self):
super(ScriptSyncCPy, self).__init__()
self._var_output = ["None"]
self._var_output = []
ghenv.Component.Message = "ScriptSyncCPy"

# self.thread = None
Expand Down Expand Up @@ -131,9 +131,11 @@ def RunScript(self, x, y):
# get the output variables defined in the script
outparam = ghenv.Component.Params.Output
outparam_names = [p.NickName for p in outparam if p.NickName != "out"]
for k, v in res.items():
if k in outparam_names:
self._var_output.append(v)
for outp in outparam_names:
if outp in res.keys():
self._var_output.append(res[outp])
else:
self._var_output.append(None)

return self._var_output

Expand All @@ -143,18 +145,22 @@ def AfterRunScript(self):
its calculation. It is used to load the GHComponent outputs
with the values created in the script.
"""
outparam = ghenv.Component.Params.Output
outparam_names = [p.NickName for p in outparam if p.NickName != "out"]
outparam = [p for p in ghenv.Component.Params.Output if p.NickName != "out"]
outparam_names = [p.NickName for p in outparam]

print(outparam_names)
print(self._var_output.keys())
print(self._var_output.values())
print(self._var_output)
# print(self._var_output.keys())
# print(self._var_output.values())

var_output_dict = dict(zip([p.NickName for p in outparam if p.NickName != "out"], self._var_output))
# print(var_output_dict)
# var_output_dict = dict(zip([p.NickName for p in outparam if p.NickName != "out"], self._var_output))
# # print(var_output_dict)

for idx, outp in enumerate(outparam):
if outp.NickName != "out":
ghenv.Component.Params.Output[idx].VolatileData.Clear()
value = var_output_dict.get(outp.NickName, "None")
ghenv.Component.Params.Output[idx].AddVolatileData(gh.Kernel.Data.GH_Path(0), 0, value)
self._var_output = ["None"]
# if outp.NickName != "out":
ghenv.Component.Params.Output[idx+1].VolatileData.Clear()
ghenv.Component.Params.Output[idx+1].AddVolatileData(gh.Kernel.Data.GH_Path(0), 0, self._var_output[idx])



self._var_output.clear()
1 change: 1 addition & 0 deletions GH/PyGH/test/runner_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
print(f"runner_script.py::y value: {y}")
a = 4
c = x + y
b = "asd"
print(f"runner_script.py::a value: {a}")

0 comments on commit 2b34eba

Please sign in to comment.