Ejemplo n.º 1
0
    def node_enum_items(self, context):
        import nodeitems_utils
        from . import node_items

        enum_items = NODE_OT_octane_add_search._enum_item_hack
        enum_items.clear()        

        for index, item in enumerate(nodeitems_utils.node_items_iter(context)):
            if isinstance(item, nodeitems_utils.NodeItem):
                if isinstance(item, node_items.OctaneNodeItem):
                    if item.is_pin_type_compatible(self.octane_pin_type):
                        new_item = True
                        for added_item in enum_items:
                            if item.label == added_item[1]:
                                new_item = False
                                break
                        if new_item:
                            enum_items.append(
                                (str(index),
                                 item.label,
                                 "",
                                 index,
                                 ))
                else:
                    # Do not show Blender's menu under quick adding mode(octane_pin_type is assigned)
                    if self.octane_pin_type == consts.PinType.PT_UNKNOWN:
                        enum_items.append(
                            (str(index),
                             item.label,
                             "",
                             index,
                             ))
        return enum_items
Ejemplo n.º 2
0
 def node_enum_items(self, context):
     enum_items = []
     for index, item in enumerate(nodeitems_utils.node_items_iter(context)):
         nodetype = getattr(bpy.types, item.nodetype, None)
         if nodetype:
             enum_items.append((str(index), item.label, nodetype.bl_rna.description, index))
     return enum_items
Ejemplo n.º 3
0
 def node_enum_items(self, context):
     enum_items = []
     for index, item in enumerate(nodeitems_utils.node_items_iter(context)):
         nodetype = getattr(bpy.types, item.nodetype, None)
         if nodetype:
             enum_items.append((str(index), item.label, nodetype.bl_rna.description, index))
     return enum_items
Ejemplo n.º 4
0
    def find_node_item(self, context):
        import nodeitems_utils

        node_item = int(self.node_item)
        for index, item in enumerate(nodeitems_utils.node_items_iter(context)):
            if index == node_item:
                return item
        return None
Ejemplo n.º 5
0
    def node_enum_items(self, context):
        enum_items = NODE_OT_add_search._enum_item_hack
        enum_items.clear()

        for index, item in enumerate(nodeitems_utils.node_items_iter(context)):
            if isinstance(item, nodeitems_utils.NodeItem):
                nodetype = getattr(bpy.types, item.nodetype, None)
                if nodetype:
                    enum_items.append((str(index), item.label, nodetype.bl_rna.description, index))
        return enum_items
Ejemplo n.º 6
0
    def node_enum_items(self, context):
        enum_items = NODE_OT_add_search._enum_item_hack
        enum_items.clear()

        for index, item in enumerate(nodeitems_utils.node_items_iter(context)):
            if isinstance(item, nodeitems_utils.NodeItem):
                nodetype = getattr(bpy.types, item.nodetype, None)
                if nodetype:
                    enum_items.append((str(index), item.label, nodetype.bl_rna.description, index))
        return enum_items
Ejemplo n.º 7
0
    def node_enum_items(self, context):
        enum_items = NODE_OT_add_search._enum_item_hack
        enum_items.clear()

        for index, item in enumerate(nodeitems_utils.node_items_iter(context)):
            if isinstance(item, nodeitems_utils.NodeItem):
                enum_items.append(
                    (str(index),
                     item.label,
                     "",
                     index,
                     ))
        return enum_items
Ejemplo n.º 8
0
    def node_enum_items(self, context):
        enum_items = NODE_OT_add_search._enum_item_hack
        enum_items.clear()

        for index, item in enumerate(nodeitems_utils.node_items_iter(context)):
            if isinstance(item, nodeitems_utils.NodeItem):
                enum_items.append(
                    (str(index),
                     item.label,
                     "",
                     index,
                     ))
        return enum_items
Ejemplo n.º 9
0
    def node_enum_items(self, context):
        enum_items = RSN_OT_SearchAndLink._enum_item_hack
        enum_items.clear()

        for index, item in enumerate(nodeitems_utils.node_items_iter(context)):
            if isinstance(item, nodeitems_utils.NodeItem):
                if item.nodetype.startswith('RSN') and item.nodetype not in {
                        'RSNodeRenderListNode'
                }:
                    continue

                enum_items.append((item.nodetype, item.label, ''))

        return enum_items
Ejemplo n.º 10
0
    def find_node_item(self, context):
        nt_debug("DEF: find_node_item")
        tmp = int(self.node_item.split()[0])
        nt_debug("FIND_NODE_ITEM: Tmp : " + str(self.node_item.split()))

        node_item = tmp
        extra = [self.node_item.split()[1], self.node_item.split()[2]]
        #nt_debug ("First extra :" + str(extra))
        #nt_debug ("Third ? :" + str(self.node_item.split()[3:]))
        nice_name = ' '.join(self.node_item.split()[3:])

        for index, item in enumerate(nodeitems_utils.node_items_iter(context)):
            #nt_debug("DEF: find_node_item")
            if index == node_item:
                return [item, extra, nice_name]
        return None
Ejemplo n.º 11
0
 def find_node_item(self, context):
     node_item = int(self.node_item)
     for index, item in enumerate(nodeitems_utils.node_items_iter(context)):
         if index == node_item:
             return item
     return None
Ejemplo n.º 12
0
 def find_node_item(self, context):
     for index, item in enumerate(nodeitems_utils.node_items_iter(context)):
         if str(index) == self.type:
             return item
     return None
Ejemplo n.º 13
0
    def node_enum_items(self, context):
        nt_debug("DEF: node_enum_items")
        enum_items = NODE_OT_add_tabber_search._enum_item_hack

        addon = bpy.context.preferences.addons['node_tabber']
        prefs = addon.preferences

        enum_items.clear()
        category = context.space_data.tree_type[0]

        if (category == "S"):
            category = "shader.json"
        if (category == "C"):
            category = "compositor.json"
        if (category == "T"):
            category = "texture.json"

        path = os.path.dirname(__file__) + "/" + category
        if not os.path.exists(path):
            content = {}
        else:
            with open(path, "r") as f:
                content = json.load(f)

        index_offset = 0
        math_index = -1
        vector_math_index = -1
        mix_rgb_index = -1

        for index, item in enumerate(nodeitems_utils.node_items_iter(context)):
            #nt_debug("DEF: node_enum_items")
            if isinstance(item, nodeitems_utils.NodeItem):

                #nt_debug(str(item.label))
                short = ''
                tally = 0
                words = item.label.split()
                for word in words:
                    short += word[0]
                match = item.label + " (" + short + ")"
                if match in content:
                    tally = content[match]['tally']

                enum_items.append((
                    str(index) + " 0 0",
                    item.label + " (" + short + ")",
                    str(tally),
                    index,
                ))
                index_offset = index

                if item.label == "Math":
                    math_index = index
                if item.label == "Vector Math":
                    vector_math_index = index
                if item.label == "MixRGB":
                    mix_rgb_index = index

        #Add sub node searching if enabled
        if prefs.sub_search:
            if math_index > -1:
                nt_debug("Adding math nodes")
                for index2, subname in enumerate(nt_extras.extra_math):
                    tally = 0
                    if subname[1] in content:
                        tally = content[subname[1]]['tally']
                    enum_items.append((
                        str(math_index) + subname[0] + " " + subname[1],
                        subname[1],
                        str(tally),
                        index_offset + 1 + index2,
                    ))
                index_offset += index2

            if vector_math_index > -1:
                nt_debug("Adding vector math nodes")
                for index2, subname in enumerate(nt_extras.extra_vector_math):
                    tally = 0
                    if subname[1] in content:
                        tally = content[subname[1]]['tally']
                    enum_items.append((
                        str(vector_math_index) + subname[0] + " " + subname[1],
                        subname[1],
                        str(tally),
                        index_offset + 1 + index2,
                    ))
                index_offset += index2

            if mix_rgb_index > -1:
                nt_debug("Adding mix rgb nodes")
                for index2, subname in enumerate(nt_extras.extra_color):
                    tally = 0
                    if subname[1] in content:
                        tally = content[subname[1]]['tally']
                    enum_items.append((
                        str(mix_rgb_index) + subname[0] + " " + subname[1],
                        subname[1],
                        str(tally),
                        index_offset + 1 + index2,
                    ))
                index_offset += index2

        if prefs.tally:
            tmp = enum_items
            tmp = sorted(enum_items, key=take_fifth, reverse=True)
        # print("\n\n" + str(tmp) + "\n\n")
        else:
            tmp = enum_items
        return tmp
Ejemplo n.º 14
0
    def node_enum_items2(self, context):
        for index, item in enumerate(nodeitems_utils.node_items_iter(context)):
            if isinstance(item, nodeitems_utils.NodeItem):
                print(str(index) + " : " + str(item.label))

        return None
Ejemplo n.º 15
0
 def find_node_item(self, context):
     for index, item in enumerate(nodeitems_utils.node_items_iter(context)):
         if str(index) == self.type:
             return item
     return None