-
-
Save zeffii/aa1097273419f3aa7730 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def update_py(self): | |
''' | |
triggered when update is called, ideally this | |
- runs script with default values for those in_sockets not connected | |
- does nothing if input is unchanged. | |
''' | |
node_function = self.node_dict[hash(self)].get('node_function', None) | |
if not node_function: | |
return | |
defaults = node_function.__defaults__ | |
input_names = [i.name for i in self.inputs] | |
fparams = [] | |
for param_idx, name in enumerate(input_names): | |
links = self.inputs[name].links | |
this_val = defaults[param_idx] | |
if links: | |
# for now it is necessary type check these, it's a bit more code | |
# but allows for nested lists. | |
if isinstance(this_val, (int, float)): | |
k = str(SvGetSocketAnyType(self, self.inputs[param_idx])) | |
kfree = k[2:-2] | |
this_val = ast.literal_eval(kfree) | |
elif isinstance(this_val, list): | |
this_val = self.inputs[param_idx].sv_get()[0] | |
fparams.append(this_val) | |
if node_function and (len(fparams) == len(input_names)): | |
fn_return_values = node_function(*fparams) | |
out_sockets = fn_return_values[1] | |
for socket_type, name, data in out_sockets: | |
SvSetSocketAnyType(self, name, data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment