Skip to content
Snippets Groups Projects
node_wrangler.py 170 KiB
Newer Older
  • Learn to ignore specific revisions
  •     (NWLinkToOutputNode.bl_idname, 'O', 'PRESS', False, False, False, None, "Link to output node"),
    
        # SELECT PARENT/CHILDREN
        # Select Children
    
        (NWSelectParentChildren.bl_idname, 'RIGHT_BRACKET', 'PRESS', False, False, False, (('option', 'CHILD'),), "Select children"),
    
        (NWSelectParentChildren.bl_idname, 'LEFT_BRACKET', 'PRESS', False, False, False, (('option', 'PARENT'),), "Select Parent"),
    
        (NWAddTextureSetup.bl_idname, 'T', 'PRESS', True, False, False, None, "Add texture setup"),
    
        (NWResetBG.bl_idname, 'Z', 'PRESS', False, False, False, None, "Reset backdrop image zoom"),
    
        (NWDeleteUnused.bl_idname, 'X', 'PRESS', False, False, True, None, "Delete unused nodes"),
    
        (NWFrameSelected.bl_idname, 'P', 'PRESS', False, True, False, None, "Frame selected nodes"),
    
        (NWSwapLinks.bl_idname, 'S', 'PRESS', False, False, True, None, "Swap Outputs"),
    
        (NWEmissionViewer.bl_idname, 'LEFTMOUSE', 'PRESS', True, True, False, None, "Connect to Cycles Viewer node"),
    
        (NWReloadImages.bl_idname, 'R', 'PRESS', False, False, True, None, "Reload images"),
    
        (NWLazyMix.bl_idname, 'RIGHTMOUSE', 'PRESS', False, False, True, None, "Lazy Mix"),
    
        (NWLazyConnect.bl_idname, 'RIGHTMOUSE', 'PRESS', True, False, False, None, "Lazy Connect"),
    
        # Lazy Connect with Menu
    
        (NWLazyConnect.bl_idname, 'RIGHTMOUSE', 'PRESS', True, True, False, (('with_menu', True),), "Lazy Connect with Socket Menu"),
        # Viewer Tile Center
        (NWViewerFocus.bl_idname, 'LEFTMOUSE', 'DOUBLE_CLICK', False, False, False, None, "Set Viewers Tile Center"),
    
        # Align Nodes
        (NWAlignNodes.bl_idname, 'EQUAL', 'PRESS', False, True, False, None, "Align selected nodes neatly in a row/column"),
    
        ('wm.call_menu', 'SPACE', 'PRESS', True, False, False, (('name', NodeWranglerMenu.bl_idname),), "Node Wranger menu"),
        ('wm.call_menu', 'SLASH', 'PRESS', False, False, False, (('name', NWAddReroutesMenu.bl_idname),), "Add Reroutes menu"),
        ('wm.call_menu', 'NUMPAD_SLASH', 'PRESS', False, False, False, (('name', NWAddReroutesMenu.bl_idname),), "Add Reroutes menu"),
        ('wm.call_menu', 'BACK_SLASH', 'PRESS', False, False, False, (('name', NWLinkActiveToSelectedMenu.bl_idname),), "Link active to selected (menu)"),
        ('wm.call_menu', 'C', 'PRESS', False, True, False, (('name', NWCopyToSelectedMenu.bl_idname),), "Copy to selected (menu)"),
        ('wm.call_menu', 'S', 'PRESS', 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.NWLazySource = StringProperty(
            name="Lazy Source!",
            default="x",
            description="An internal property used to store the first node in a Lazy Connect operation")
        bpy.types.Scene.NWLazyTarget = StringProperty(
            name="Lazy Target!",
    
            description="An internal property used to store the last node in a Lazy Connect operation")
        bpy.types.Scene.NWSourceSocket = IntProperty(
            name="Source Socket!",
            default=0,
            description="An internal property used to store the source socket in a Lazy Connect operation")
    
        bpy.utils.register_module(__name__)
    
        addon_keymaps.clear()
        kc = bpy.context.window_manager.keyconfigs.addon
        if kc:
            km = kc.keymaps.new(name='Node Editor', space_type="NODE_EDITOR")
    
            for (identifier, key, action, CTRL, SHIFT, ALT, props, nicename) in kmi_defs:
                kmi = km.keymap_items.new(identifier, key, action, 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)
    
        bpy.types.NODE_MT_category_SH_NEW_TEXTURE.prepend(multipleimages_menu_func)
        bpy.types.NODE_PT_category_SH_NEW_TEXTURE.prepend(multipleimages_menu_func)
        bpy.types.NODE_MT_category_CMP_INPUT.prepend(multipleimages_menu_func)
        bpy.types.NODE_PT_category_CMP_INPUT.prepend(multipleimages_menu_func)
    
        # props
        del bpy.types.Scene.NWBusyDrawing
    
        del bpy.types.Scene.NWLazySource
        del bpy.types.Scene.NWLazyTarget
        del bpy.types.Scene.NWSourceSocket
    
        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)
    
        bpy.types.NODE_MT_category_SH_NEW_TEXTURE.remove(multipleimages_menu_func)
        bpy.types.NODE_PT_category_SH_NEW_TEXTURE.remove(multipleimages_menu_func)
        bpy.types.NODE_MT_category_CMP_INPUT.remove(multipleimages_menu_func)
        bpy.types.NODE_PT_category_CMP_INPUT.remove(multipleimages_menu_func)
    
        bpy.utils.unregister_module(__name__)
    
    
    if __name__ == "__main__":