def serialize_inputs(node): arglist = [] for socket in node.inputs: variable_result = socket.fgetx() if isinstance(variable_result, str): if variable_result.endswith('__'): final_arg = variable_result else: final_arg = global_name(node) + socket.name arglist.append(final_arg) stringified_arglist = ', '.join(arglist) rate = audiorate_dict.get(node.sp_rate) return '{0}.{1}({2})'.format(node.bl_label, rate, stringified_arglist)
def get_args(self): varname = self.get_varname() sanitized_name = global_name(self) args = serialize_inputs(self) part2 = "" if hasattr(self, 'modifiers') and self.modifiers: ops = modifier_rewrites.get(self.modifier_type) if ops[0] == 1: part2 = ops[1].format( round(self.modifier_xf, 6)) if ops[0] == 2: part2 = ops[1].format( round(self.modifier_xf, 6), round(self.modifier_yf, 6)) part1 = 'var {0} = {1}'.format(sanitized_name, args) return part1 + part2 + ';'
def updateSD(self, context): ''' Update Self and Downstream. Whenever a property has this function attached, it passes update requests to the node it came from and the nodes that are downstream from it. TLDR; This propagates changes into the dependency graph. ''' if hasattr(context, 'socket'): short_paramname = context.socket.name paramname = global_name(self) + short_paramname paramvalue = self.inputs[short_paramname].fgetx() print(paramname, paramvalue) if osc_statemachine: if osc_statemachine['status'] == RUNNING: send_synthdef_osc_update(paramname, paramvalue) self.process() trigger_node = self ng = context.space_data.node_tree # if trigger_node has no socket connecting from it, end early links_first_pass = [i.from_node for i in ng.links] if not trigger_node in links_first_pass: return apex = get_apex(ng) L = prototype_cascade(ng, apex) # set the cache for the apex nodes for node in apex: node.process() #node.select = True # do full retrig for node in L: node.process()
def process(self): if not self.sp_args: return # if inputs does not match number of args, return early. if not len(self.inputs) == (self.sp_args.count(',') + 1): return sanitized_name = global_name(self) self.outputs[0].fset(sanitized_name) for socket in self.inputs: variable_result = socket.fgetx() if isinstance(variable_result, str): if variable_result.endswith('__'): continue if isinstance(variable_result, bool): variable_result = str(variable_result).lower() if isinstance(variable_result, float): variable_result = round(variable_result, 5) store_variable(self, socket.name, variable_result)
def get_args(self): varname = self.get_varname() sanitized_name = global_name(self) args = serialize_inputs(self) return '{0};'.format(args)