Skip to content
Snippets Groups Projects
node_efficiency_tools.py 131 KiB
Newer Older
  • Learn to ignore specific revisions
  •         (('mode', 'ADD'), ('merge_type', 'MATH'),), "Merge Nodes (Math, Add)"),
        (NWMergeNodes.bl_idname, 'EQUAL', True, True, False,
            (('mode', 'ADD'), ('merge_type', 'MATH'),), "Merge Nodes (Math, Add)"),
        (NWMergeNodes.bl_idname, 'NUMPAD_ASTERIX', True, True, False,
            (('mode', 'MULTIPLY'), ('merge_type', 'MATH'),), "Merge Nodes (Math, Multiply)"),
        (NWMergeNodes.bl_idname, 'EIGHT', True, True, False,
            (('mode', 'MULTIPLY'), ('merge_type', 'MATH'),), "Merge Nodes (Math, Multiply)"),
        (NWMergeNodes.bl_idname, 'NUMPAD_MINUS', True, True, False,
            (('mode', 'SUBTRACT'), ('merge_type', 'MATH'),), "Merge Nodes (Math, Subtract)"),
        (NWMergeNodes.bl_idname, 'MINUS', True, True, False,
            (('mode', 'SUBTRACT'), ('merge_type', 'MATH'),), "Merge Nodes (Math, Subtract)"),
        (NWMergeNodes.bl_idname, 'NUMPAD_SLASH', True, True, False,
            (('mode', 'DIVIDE'), ('merge_type', 'MATH'),), "Merge Nodes (Math, Divide)"),
        (NWMergeNodes.bl_idname, 'SLASH', True, True, False,
            (('mode', 'DIVIDE'), ('merge_type', 'MATH'),), "Merge Nodes (Math, Divide)"),
        (NWMergeNodes.bl_idname, 'COMMA', True, True, False,
            (('mode', 'LESS_THAN'), ('merge_type', 'MATH'),), "Merge Nodes (Math, Less than)"),
        (NWMergeNodes.bl_idname, 'PERIOD', True, True, False,
            (('mode', 'GREATER_THAN'), ('merge_type', 'MATH'),), "Merge Nodes (Math, Greater than)"),
    
        # BATCH CHANGE NODES
    
        # NWBatchChangeNodes with Alt
        (NWBatchChangeNodes.bl_idname, 'NUMPAD_0', False, False, True,
            (('blend_type', 'MIX'), ('operation', 'CURRENT'),), "Batch change blend type (Mix)"),
        (NWBatchChangeNodes.bl_idname, 'ZERO', False, False, True,
            (('blend_type', 'MIX'), ('operation', 'CURRENT'),), "Batch change blend type (Mix)"),
        (NWBatchChangeNodes.bl_idname, 'NUMPAD_PLUS', False, False, True,
            (('blend_type', 'ADD'), ('operation', 'ADD'),), "Batch change blend type (Add)"),
        (NWBatchChangeNodes.bl_idname, 'EQUAL', False, False, True,
            (('blend_type', 'ADD'), ('operation', 'ADD'),), "Batch change blend type (Add)"),
        (NWBatchChangeNodes.bl_idname, 'NUMPAD_ASTERIX', False, False, True,
            (('blend_type', 'MULTIPLY'), ('operation', 'MULTIPLY'),), "Batch change blend type (Multiply)"),
        (NWBatchChangeNodes.bl_idname, 'EIGHT', False, False, True,
            (('blend_type', 'MULTIPLY'), ('operation', 'MULTIPLY'),), "Batch change blend type (Multiply)"),
        (NWBatchChangeNodes.bl_idname, 'NUMPAD_MINUS', False, False, True,
            (('blend_type', 'SUBTRACT'), ('operation', 'SUBTRACT'),), "Batch change blend type (Subtract)"),
        (NWBatchChangeNodes.bl_idname, 'MINUS', False, False, True,
            (('blend_type', 'SUBTRACT'), ('operation', 'SUBTRACT'),), "Batch change blend type (Subtract)"),
        (NWBatchChangeNodes.bl_idname, 'NUMPAD_SLASH', False, False, True,
            (('blend_type', 'DIVIDE'), ('operation', 'DIVIDE'),), "Batch change blend type (Divide)"),
        (NWBatchChangeNodes.bl_idname, 'SLASH', False, False, True,
            (('blend_type', 'DIVIDE'), ('operation', 'DIVIDE'),), "Batch change blend type (Divide)"),
        (NWBatchChangeNodes.bl_idname, 'COMMA', False, False, True,
            (('blend_type', 'CURRENT'), ('operation', 'LESS_THAN'),), "Batch change blend type (Current)"),
        (NWBatchChangeNodes.bl_idname, 'PERIOD', False, False, True,
            (('blend_type', 'CURRENT'), ('operation', 'GREATER_THAN'),), "Batch change blend type (Current)"),
        (NWBatchChangeNodes.bl_idname, 'DOWN_ARROW', False, False, True,
            (('blend_type', 'NEXT'), ('operation', 'NEXT'),), "Batch change blend type (Next)"),
        (NWBatchChangeNodes.bl_idname, 'UP_ARROW', False, False, True,
            (('blend_type', 'PREV'), ('operation', 'PREV'),), "Batch change blend type (Previous)"),
    
        # LINK ACTIVE TO SELECTED
    
        # Don't use names, don't replace links (K)
    
        (NWLinkActiveToSelected.bl_idname, 'K', False, False, False,
            (('replace', False), ('use_node_name', False), ('use_outputs_names', False),), "Link active to selected (Don't replace links)"),
    
        # Don't use names, replace links (Shift K)
    
        (NWLinkActiveToSelected.bl_idname, 'K', False, True, False,
            (('replace', True), ('use_node_name', False), ('use_outputs_names', False),), "Link active to selected (Replace links)"),
    
        # Use node name, don't replace links (')
    
        (NWLinkActiveToSelected.bl_idname, 'QUOTE', False, False, False,
            (('replace', False), ('use_node_name', True), ('use_outputs_names', False),), "Link active to selected (Don't replace links, node names)"),
        # Use node name, replace links (Shift ')
        (NWLinkActiveToSelected.bl_idname, 'QUOTE', False, True, False,
            (('replace', True), ('use_node_name', True), ('use_outputs_names', False),), "Link active to selected (Replace links, node names)"),
        # Don't use names, don't replace links (;)
        (NWLinkActiveToSelected.bl_idname, 'SEMI_COLON', False, False, False,
            (('replace', False), ('use_node_name', False), ('use_outputs_names', True),), "Link active to selected (Don't replace links, output names)"),
    
        # Don't use names, replace links (')
    
        (NWLinkActiveToSelected.bl_idname, 'SEMI_COLON', False, True, False,
            (('replace', True), ('use_node_name', False), ('use_outputs_names', True),), "Link active to selected (Replace links, output names)"),
    
        # CHANGE MIX FACTOR
    
        (NWChangeMixFactor.bl_idname, 'LEFT_ARROW', False, False, True, (('option', -0.1),), "Reduce Mix Factor by 0.1"),
        (NWChangeMixFactor.bl_idname, 'RIGHT_ARROW', False, False, True, (('option', 0.1),), "Increase Mix Factor by 0.1"),
        (NWChangeMixFactor.bl_idname, 'LEFT_ARROW', False, True, True, (('option', -0.01),), "Reduce Mix Factor by 0.01"),
        (NWChangeMixFactor.bl_idname, 'RIGHT_ARROW', False, True, True, (('option', 0.01),), "Increase Mix Factor by 0.01"),
        (NWChangeMixFactor.bl_idname, 'LEFT_ARROW', True, True, True, (('option', 0.0),), "Set Mix Factor to 0.0"),
        (NWChangeMixFactor.bl_idname, 'RIGHT_ARROW', True, True, True, (('option', 1.0),), "Set Mix Factor to 1.0"),
        (NWChangeMixFactor.bl_idname, 'NUMPAD_0', True, True, True, (('option', 0.0),), "Set Mix Factor to 0.0"),
        (NWChangeMixFactor.bl_idname, 'ZERO', True, True, True, (('option', 0.0),), "Set Mix Factor to 0.0"),
        (NWChangeMixFactor.bl_idname, 'NUMPAD_1', True, True, True, (('option', 1.0),), "Mix Factor to 1.0"),
        (NWChangeMixFactor.bl_idname, 'ONE', True, True, True, (('option', 1.0),), "Set Mix Factor to 1.0"),
    
        # CLEAR LABEL (Alt L)
    
        (NWClearLabel.bl_idname, 'L', False, False, True, (('option', False),), "Clear node labels"),
        # MODIFY LABEL (Alt Shift L)
        (NWModifyLabels.bl_idname, 'L', False, True, True, None, "Modify node labels"),
        # Copy Label from active to selected
        (NWCopyLabel.bl_idname, 'V', False, True, False, (('option', 'FROM_ACTIVE'),), "Copy label from active to selected"),
    
    Bartek Skorupa's avatar
    Bartek Skorupa committed
        # DETACH OUTPUTS (Alt Shift D)
    
        (NWDetachOutputs.bl_idname, 'D', False, True, True, None, "Detach outputs"),
    
    Bartek Skorupa's avatar
    Bartek Skorupa committed
        # LINK TO OUTPUT NODE (O)
    
        (NWLinkToOutputNode.bl_idname, 'O', False, False, False, None, "Link to output node"),
    
        # SELECT PARENT/CHILDREN
        # Select Children
    
        (NWSelectParentChildren.bl_idname, 'RIGHT_BRACKET', False, False, False, (('option', 'CHILD'),), "Select children"),
    
        (NWSelectParentChildren.bl_idname, 'LEFT_BRACKET', False, False, False, (('option', 'PARENT'),), "Select Parent"),
    
        (NWAddTextureSetup.bl_idname, 'T', True, False, False, None, "Add texture setup"),
        # Reset backdrop
        (NWResetBG.bl_idname, 'Z', False, False, False, None, "Reset backdrop image zoom"),
        # Delete unused
        (NWDeleteUnused.bl_idname, 'X', False, False, True, None, "Delete unused nodes"),
        # Frame Seleted
        (NWFrameSelected.bl_idname, 'P', False, True, False, None, "Frame selected nodes"),
        # Swap Outputs
        (NWSwapOutputs.bl_idname, 'S', False, False, True, None, "Swap Outputs"),
        # Emission Viewer
        (NWEmissionViewer.bl_idname, 'LEFTMOUSE', True, True, False, None, "Connect to Cycles Viewer node"),
        # Reload Images
        (NWReloadImages.bl_idname, 'R', False, False, True, None, "Reload images"),
        # Lazy Mix
        (NWLazyMix.bl_idname, 'RIGHTMOUSE', False, False, True, None, "Lazy Mix"),
        # Lazy Connect
        (NWLazyConnect.bl_idname, 'RIGHTMOUSE', True, False, False, None, "Lazy Connect"),
    
        ('wm.call_menu', 'SPACE', True, False, False, (('name', NodeWranglerMenu.bl_idname),), "Node Wranger menu"),
        ('wm.call_menu', 'SLASH', False, False, False, (('name', NWAddReroutesMenu.bl_idname),), "Add Reroutes menu"),
        ('wm.call_menu', 'NUMPAD_SLASH', False, False, False, (('name', NWAddReroutesMenu.bl_idname),), "Add Reroutes menu"),
        ('wm.call_menu', 'EQUAL', False, True, False, (('name', NWNodeAlignMenu.bl_idname),), "Node alignment menu"),
        ('wm.call_menu', 'BACK_SLASH', False, False, False, (('name', NWLinkActiveToSelectedMenu.bl_idname),), "Link active to selected (menu)"),
        ('wm.call_menu', 'C', False, True, False, (('name', NWCopyToSelectedMenu.bl_idname),), "Copy to selected (menu)"),
        ('wm.call_menu', 'S', False, True, False, (('name', NWSwitchNodeTypeMenu.bl_idname),), "Switch node type menu"),
    )
    
        # props
        bpy.types.Scene.NWBusyDrawing = StringProperty(
            name="Busy Drawing!",
            default="",
            description="An internal property used to store only the first mouse position")
        bpy.types.Scene.NWDrawColType = StringProperty(
            name="Color Type!",
            default="x",
            description="An internal property used to store the line color")
    
    
        bpy.utils.register_module(__name__)
    
        km = bpy.context.window_manager.keyconfigs.addon.keymaps.new(name='Node Editor', space_type="NODE_EDITOR")
    
        for (identifier, key, CTRL, SHIFT, ALT, props, nicename) in kmi_defs:
    
            kmi = km.keymap_items.new(identifier, key, 'PRESS', ctrl=CTRL, shift=SHIFT, alt=ALT)
            if props:
                for prop, value in props:
                    setattr(kmi.properties, prop, value)
            addon_keymaps.append((km, kmi))
    
        # menu items
        bpy.types.NODE_MT_select.append(select_parent_children_buttons)
    
        bpy.types.NODE_MT_category_SH_NEW_INPUT.prepend(attr_nodes_menu_func)
        bpy.types.NODE_PT_category_SH_NEW_INPUT.prepend(attr_nodes_menu_func)
        bpy.types.NODE_PT_backdrop.append(bgreset_menu_func)
    
        # props
        del bpy.types.Scene.NWBusyDrawing
        del bpy.types.Scene.NWDrawColType
    
    
        bpy.utils.unregister_module(__name__)
    
        for km, kmi in addon_keymaps:
            km.keymap_items.remove(kmi)
        addon_keymaps.clear()
    
    
        # menuitems
        bpy.types.NODE_MT_select.remove(select_parent_children_buttons)
        bpy.types.NODE_MT_category_SH_NEW_INPUT.remove(attr_nodes_menu_func)
        bpy.types.NODE_PT_category_SH_NEW_INPUT.remove(attr_nodes_menu_func)
        bpy.types.NODE_PT_backdrop.remove(bgreset_menu_func)
    
    
    if __name__ == "__main__":