Beispiel #1
0
    def process_node(self, context):
        '''
        Doesn't work as intended, inherited functions can't be used for bpy.props
        update= ...
        Still this is called from updateNode
        '''
        if self.id_data.bl_idname == "SverchCustomTreeType":
            if self.id_data.skip_tree_update:
                return

            # self.id_data.has_changed = True

            if data_structure.DEBUG_MODE:
                a = time.perf_counter()
                process_from_node(self)
                b = time.perf_counter()
                debug("Partial update from node %s in %s", self.name, round(b - a, 4))
            else:
                process_from_node(self)
        elif self.id_data.bl_idname == "SverchGroupTreeType":
            monad = self.id_data
            for instance in monad.instances:
                instance.process_node(context)
        elif self.id_data.bl_idname == "SvGroupTree":
            self.id_data.update_nodes([self])
        else:
            pass
Beispiel #2
0
 def update_nodes(self, nodes):
     """This method expects to get list of its nodes which should be updated"""
     if len(nodes) == 1:
         # this function actually doing something different unlike `process_from_nodes` function
         # the difference is that process_from_nodes can also update other outdated nodes
         process_from_node(nodes[0])
     process_from_nodes(nodes)
Beispiel #3
0
    def execute(self, context):

        ng = context.space_data.edit_tree
        nodes = [n for n in ng.nodes if n.select]

        if not nodes:
            self.report({"CANCELLED"}, "No nodes selected")
            return {'CANCELLED'}

        bpy.ops.node.clipboard_copy()

        if self.use_relinking:
            # get links for relinking sockets in monad IO
            links = collect_links(ng)

        monad = monad_make(self.group_name)

        # by appending, space_data is now different
        path = context.space_data.path
        path.append(monad)

        bpy.ops.node.clipboard_paste()

        # get optimal location for IO nodes..
        i_loc, o_loc = propose_io_locations(nodes)
        monad.input_node.location = i_loc
        monad.output_node.location = o_loc

        if self.use_relinking:
            re_links = link_monad(monad, links)
        """
         the monad is created, create a the class and then with class
         create the node, place and link it up
        """
        cls_ref = monad.update_cls()
        parent_node = ng.nodes.new(cls_ref.bl_idname)
        parent_node.select = False
        parent_node.location = average_of_selected(nodes)

        # remove nodes from parent_tree
        for n in nodes:
            ng.nodes.remove(n)

        # relink the new node
        if self.use_relinking:
            link_monad_instance(parent_node, re_links)

        # to make it pretty we pop and then append with the node
        path.pop()
        path.append(monad, node=parent_node)

        bpy.ops.node.view_all()

        # requires (todo) a final ntree update here
        process_from_node(parent_node)
        return {'FINISHED'}
Beispiel #4
0
 def update_nodes(self, nodes):
     """This method expects to get list of its nodes which should be updated"""
     if self.id_data.skip_tree_update:
         # this can be called by node groups which do not know whether the tree is throttled
         return
     if len(nodes) == 1:
         # this function actually doing something different unlike `process_from_nodes` function
         # the difference is that process_from_nodes can also update other outdated nodes
         process_from_node(nodes[0])
     process_from_nodes(nodes)
Beispiel #5
0
 def process_node(self, context):
     '''
     Doesn't work as intended, inherited functions can't be used for bpy.props
     update= ...
     Still this is called from updateNode
     '''
     if self.id_data.is_frozen():
         return
     if data_structure.DEBUG_MODE:
         a = time.perf_counter()
         process_from_node(self)
         b = time.perf_counter()
         print("Partial update from node", self.name, "in", round(b - a, 4))
     else:
         process_from_node(self)
Beispiel #6
0
 def process_node(self, context):
     '''
     Doesn't work as intended, inherited functions can't be used for bpy.props
     update= ...
     Still this is called from updateNode
     '''
     if self.id_data.is_frozen():
         return
     if data_structure.DEBUG_MODE:
         a = time.perf_counter()
         process_from_node(self)
         b = time.perf_counter()
         print("Partial update from node", self.name, "in", round(b-a, 4))
     else:
         process_from_node(self)
Beispiel #7
0
    def process_node(self, context):
        '''
        Doesn't work as intended, inherited functions can't be used for bpy.props
        update= ...
        Still this is called from updateNode
        '''
        if self.id_data.bl_idname == "SverchCustomTreeType":
            if self.id_data.is_frozen():
                return

            # self.id_data.has_changed = True

            if data_structure.DEBUG_MODE:
                a = time.perf_counter()
                process_from_node(self)
                b = time.perf_counter()
                debug("Partial update from node %s in %s", self.name, round(b - a, 4))
            else:
                process_from_node(self)
        elif self.id_data.bl_idname == "SverchGroupTreeType":
            monad = self.id_data
            for instance in monad.instances:
                instance.process_node(context)
        else:
            pass

        
        def free(self):
            """
            some nodes require additional operations upon node removal
            """

            if hasattr(self, "has_3dview_props"):
                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}')
Beispiel #8
0
    def process_node(self, context):
        '''
        Doesn't work as intended, inherited functions can't be used for bpy.props
        update= ...
        Still this is called from updateNode
        '''
        if self.id_data.bl_idname == "SverchCustomTreeType":
            if self.id_data.is_frozen():
                return

            if data_structure.DEBUG_MODE:
                a = time.perf_counter()
                process_from_node(self)
                b = time.perf_counter()
                debug("Partial update from node %s in %s", self.name, round(b - a, 4))
            else:
                process_from_node(self)
        elif self.id_data.bl_idname == "SverchGroupTreeType":
            monad = self.id_data
            for instance in monad.instances:
                instance.process_node(context)
        else:
            pass
Beispiel #9
0
    def process_node(self, context):
        '''
        Doesn't work as intended, inherited functions can't be used for bpy.props
        update= ...
        Still this is called from updateNode
        '''
        if self.id_data.bl_idname == "SverchCustomTreeType":
            if self.id_data.is_frozen():
                return

            if data_structure.DEBUG_MODE:
                a = time.perf_counter()
                process_from_node(self)
                b = time.perf_counter()
                print("Partial update from node", self.name, "in", round(b - a, 4))
            else:
                process_from_node(self)
        elif self.id_data.bl_idname == "SverchGroupTreeType":
            monad = self.id_data
            for instance in monad.instances:
                instance.process_node(context)
        else:
            pass
Beispiel #10
0
 def execute(self, context):
     node = bpy.data.node_groups[self.node_tree].nodes[self.node_name]
     node.active = True
     process_from_node(node)
     node.active = False
     return {'FINISHED'}