def update(self): """ The method will be triggered upon editor changes, typically before node tree update method. It is better to avoid using this trigger. """ CurrentEvents.new_event(BlenderEventsTypes.node_update, self) self.sv_update()
def updateNode(self, context): """ When a node has changed state and need to call a partial update. For example a user exposed bpy.prop """ CurrentEvents.new_event(BlenderEventsTypes.node_property_update, self) self.process_node(context)
def sv_handler_undo_post(scene): CurrentEvents.new_event(BlenderEventsTypes.undo) # this function appears to be hoisted into an environment that does not have the same locals() # hence this dict must be imported. (jan 2019) from sverchok.core import undo_handler_node_count num_to_test_against = 0 links_changed = False for ng in sverchok_trees(): num_to_test_against += len(ng.nodes) ng.sv_links.create_new_links(ng) links_changed = ng.sv_links.links_have_changed(ng) if links_changed: break if links_changed or not (undo_handler_node_count['sv_groups'] == num_to_test_against): print('looks like a node was removed, cleaning') sv_clean(scene) for ng in sverchok_trees(): ng.nodes_dict.load_nodes(ng) ng.has_changed = True sv_main_handler(scene) undo_handler_node_count['sv_groups'] = 0
def init(self, context): """ this function is triggered upon node creation, - freezes the node - delegates further initialization information to sv_init - sets node color - unfreezes the node - sets custom defaults (nodes, and sockets) """ CurrentEvents.new_event(BlenderEventsTypes.add_node, self) ng = self.id_data ng.freeze() ng.nodes_dict.load_node(self) if hasattr(self, "sv_init"): try: ng.configuring_new_node = True self.sv_init(context) except Exception as err: print('nodetree.node.sv_init failure - stare at the error message below') sys.stderr.write('ERROR: %s\n' % str(err)) ng.configuring_new_node = False self.set_color() ng.unfreeze() if not ng.limited_init: # print('applying default for', self.name) set_defaults_if_defined(self)
def init(self, context): """ this function is triggered upon node creation, - freezes the node - delegates further initialization information to sv_init - sets node color - unfreezes the node """ CurrentEvents.new_event(BlenderEventsTypes.add_node, self) ng = self.id_data if ng.bl_idname == 'SvGroupTree': self.sv_init(context) else: ng.freeze() ng.nodes_dict.load_node(self) if hasattr(self, "sv_init"): try: self.sv_init(context) except Exception as err: print( 'nodetree.node.sv_init failure - stare at the error message below' ) sys.stderr.write('ERROR: %s\n' % str(err)) self.set_color() ng.unfreeze()
def free(self): """ This method is not supposed to be overriden in specific nodes. Override sv_free() instead """ CurrentEvents.new_event(BlenderEventsTypes.free_node, self) self.sv_free() for s in self.outputs: s.sv_forget() node_tree = self.id_data if node_tree.bl_idname in { 'SverchCustomTreeType', 'SverchGroupTreeType' }: node_tree.nodes_dict.forget_node(self) if hasattr(self, "has_3dview_props"): # todo remove print("about to remove this node's props from Sv3DProps") try: bpy.ops.node.sv_remove_3dviewpropitem( node_name=self.name, tree_name=self.id_data.name) except: print( f'failed to remove {self.name} from tree={self.id_data.name}' )
def copy(self, original): """ This method is not supposed to be overriden in specific nodes. Override sv_copy() instead. """ CurrentEvents.new_event(BlenderEventsTypes.copy_node, self) settings = get_original_node_color(self.id_data, original.name) if settings is not None: self.use_custom_color, self.color = settings self.sv_copy(original) self.n_id = "" self.id_data.nodes_dict.load_node(self)
def sv_update_handler(scene): """ Update sverchok node groups on frame change events. """ if not has_frame_changed(scene): return CurrentEvents.new_event(BlenderEventsTypes.frame_change) for ng in sverchok_trees(): try: # print('sv_update_handler') ng.process_ani() except Exception as e: print('Failed to update:', str(e)) # name,
def update(self): """ This method is called if collection of nodes or links of the tree was changed First of all it checks is it worth bothering and then gives initiative to `update system` """ CurrentEvents.new_event(BlenderEventsTypes.tree_update, self) # this is a no-op if there's no drawing clear_exception_drawing_with_bgl(self.nodes) if is_first_run(): return if self.skip_tree_update or not self.sv_process: return self.sv_update() self.has_changed = False
def init(self, context): """ this function is triggered upon node creation, - throttle the node - delegates further initialization information to sv_init - sets node color """ CurrentEvents.new_event(BlenderEventsTypes.add_node, self) ng = self.id_data if ng.bl_idname in {'SverchCustomTreeType', 'SverchGroupTreeType'}: ng.nodes_dict.load_node(self) with ng.throttle_update(): try: self.sv_init(context) except Exception as err: print('nodetree.node.sv_init failure - stare at the error message below') sys.stderr.write('ERROR: %s\n' % str(err)) self.set_color()
def update(self): ''' Tags tree for update for handle get update list for debug info, tuple (fulllist, dictofpartiallists) ''' CurrentEvents.new_event(BlenderEventsTypes.tree_update, self) # this is a no-op if there's no drawing clear_exception_drawing_with_bgl(self.nodes) if is_first_run(): return if self.skip_tree_update: # print('throttled update from context manager') return if self.configuring_new_node or self.is_frozen() or not self.sv_process: return self.sv_update() self.has_changed = False
def insert_link(self, link): """It will be triggered only if one socket is connected with another by user""" CurrentEvents.new_event(BlenderEventsTypes.add_link_to_node, self)
def update(self): CurrentEvents.new_event(BlenderEventsTypes.monad_tree_update, self) affected_trees = {instance.id_data for instance in self.instances} for tree in affected_trees: tree.update()
def insert_link(self, link): CurrentEvents.new_event(BlenderEventsTypes.add_link_to_node, self)
def update(self): CurrentEvents.new_event(BlenderEventsTypes.node_update, self) self.sv_update()