Quick tool from shelf for Menu items

Quick tool from shelf for Menu items

agnisen07
Enthusiast Enthusiast
696 Views
1 Reply
Message 1 of 2

Quick tool from shelf for Menu items

agnisen07
Enthusiast
Enthusiast

Hi,

I wanted to know if there's a way to quickly add a custom tool for an option from any of the menus as required.

 

For example:

1. A custom tool that will open the FCurves option from the Windows menu.
OR

2. A custom tool that will run Select All option from the Edit menu.

 

For reference, Maya has the Ctrl + Shift + Select on that menu option to create a quick select tool in the shelf. It's very handy.


Do I need to call any function from that specific module in the Run Code dialog space for a custom tool?

Is there any quick way for this?

 

Any suggestions or leads are greatly appreciated!
Thanks
Peace

0 Likes
Accepted solutions (1)
697 Views
1 Reply
Reply (1)
Message 2 of 2

Mocappy
Advocate
Advocate
Accepted solution

Yeah, this was a fun one 🙂

 

You can access the menu options with FBMenuManger()... and then you SHOULD be able to call menu operations using the full path name from the menu. For example, "Edit/&Undo\tCtrl+Z"

 

BUT...some of the menu item names have the "&" in the middle of the name?!?! For example, FC&urves, De&lete and D&eselect.

 

Luckily, there is a way to find the names and id's off all the items in a menu.

 

from pyfbsdk import FBMenuManager

def print_menu_item_name_id_keyboardShortcut(menuName):
    menuManager = FBMenuManager() 
    editMenu = menuManager.GetMenu(menuName)
    item = editMenu.GetFirstItem()
    while item:
        print "'" + item.Caption + "' (id: " + str( item.Id ) + ")"
        item = editMenu.GetNextItem( item )

print_menu_item_name_id_keyboardShortcut("Window")

menuManager = FBMenuManager()
menuName = "Window"
menuItemName = "FC&urves"
keyboardShortCut = ""#"\tCtrl+Shift+2" # Keyboard shortcuts are tabbed. If none, set to ""

menuItemFullPath = "{}/{}{}".format(menuName, menuItemName, keyboardShortCut)
print menuManager.ExecuteMenuItemFromFullPath( menuItemFullPath )

 

Hopefully some of this will help,