Markingmenu Extension

See Marking Creation for usages.

Markingmenuoverride

reset()
setup()

Installs modifications to the dagProcMenu script for the current session

Menu

Usage:

First define to location of your commands and marking menu classes. 
Next define the location of your layout files
Now apply these locations to the MM environment variables, ZOO_MM_COMMAND_PATH, 
    ZOO_MM_MENU_PATH, ZOO_MM_LAYOUT_PATH, before zootools starts up.
exception InvalidJsonFileFormat

Bases: Exception

Raised in case of invalid formatted json file(.mmlayout)

exception MissingMarkingMenu

Bases: Exception

findLayout(layoutId)

Finds the layout by Id(str) from the layout registry

Parameters

layoutId (str) – the layout str id, “some.layout.id”

Returns

If the registry has the id then a Layout object will be returned

Return type

Layout or None

class Registry(*args, **kwargs)

Bases: object

This holds all currently available layout classes discovered in the environment use findLayout() to get the layout from this registry.

To setup the environment you need to set the environment variable :env:’ZOO_MM_LAYOUT_PATH’ to the directories of the layout, each path should be separated using os.pathsep

LAYOUT_ENV = 'ZOO_MM_LAYOUT_PATH'
MENU_ENV = 'ZOO_MM_MENU_PATH'
COMMAND_ENV = 'ZOO_MM_COMMAND_PATH'
STATIC_LAYOUT_TYPE = 0
DYNAMIC_TYPE = 1
hasMenu(menuId)
menuType(menuId)
env()
registerLayoutByEnv(env)

Recursively Registers all layout files with the extension .mmlayout and loads the json data with a layout instance then adds to the layouts cache

Parameters

env (str) – the environment variable pointing to the parent directory

registerLayoutData(data)

Adds the layout data structure as a Layout using the data[“id”] as the key.

Parameters

data (dict) – see :class`Layout`

class Layout(**kwargs)

Bases: dict

layoutData={"items":{"N": {},
                      "NW": {},
                      "W": {},
                      "SW": {},
                      "S": {},
                      "SE": {},
                      "E": {},
                      "NE": {},
                      "generic": [{"type": "menu",
                                  "name": "Testmenu",
                                  "children": [{"type": "command",
                                                "id": ""}
                                                ]
                                  ]

                      },
            "id": "some.layout.id"}
layoutObj = Layout(**layoutData)
items()

Returns the item dict for this layout in the form of

{"N": {},
"NW": {},
"W": {},
"SW": {},
"S": {},
"SE": {},
"E": {},
"NE": {},
"generic": [{"type": "menu",
            "name": "Testmenu",
            "children": [{"type": "command",
                          "id": ""}
                          ]]
}
Returns

The layout items dict.

Return type

dict

merge(layout)

Merges the layout items into this instance, only differences will be merged.

Parameters

layout (Layout) – the layout to merge into the this class

validate(layout=None)

Recursively validates the layout, returning all failed items, if an item references another layout that layout will used be validated.

Parameters

layout (Layout) – The layout instance to solve

Returns

the failed items

Return type

list

solve()

Recursively solves the layout by expanding any @layout.id references which will compose a single dict ready for use.

A layout can contain deeply nested layouts which is referenced by the syntax @layout.id, in the case where there is a reference then that layout will be solved first.

Returns

Whether or not the layout was solved

Return type

bool

class MarkingMenu(layout, name, parent, registry)

Bases: object

Maya MarkingMenu wrapper object to support zoocommands and python executable code. MM layouts are defined by the Layout instance class

static removeExistingMenu(menuName)

Removes the menuName from the registry and deletes the menu from maya

Parameters

menuName (str) – The menu name to remove.

static removeAllActiveMenus()

Removes all current active zoo marking menus from the registry and deletes the Maya UI MM

classmethod buildFromLayout(layoutId, menuName, parent, options, globalArguments=None)

Build a menu menu directly from the menu registry based off of the layout Id.

Parameters
  • layoutId (str) – The layout id defined in the registry

  • menuName (str) – The unique name for the menu

  • parent (str) – The maya widget path for the menu parent i.e viewPanes

  • options (dict) – The marking menu options, see MarkingMenu.__init__ for more details

  • globalArguments (dict) – The global Arguments to pass to all menu action commands.

Returns

The new markingMenu instance

Return type

MarkingMenu

Raise

ValueError, in the case the layout can’t be found or already active.

classmethod buildFromLayoutData(layoutData, menuName, parent, options, arguments=None)
static buildDynamicMenu(clsId, parent, arguments, layout=None)

Builds a marking menu from the clsId which should exist with our marking menu registry.

Parameters
  • clsId (str) – the classId string

  • parent (str) – The parent menu or widget fullPath ie. viewPanes for mayas viewport.

  • arguments (dict) – The arguments to pass to the custom menu class

Returns

If the classid exists then the newly created marking menu class will be returned

Return type

MarkingMenu or None

asQObject()

Returns this markingMenu as a PYQT object

Returns

Return this MarkingMenu as a qt.QMenu instance

Return type

QMenu

attach(**arguments)

Generate’s the marking menu using the parent marking menu.

The arguments passed will be passed to ech and every menuItem command, for example if the menu item command is a zoocommand then the zoocommand will have the arguments passed to it.

Parameters

arguments (dict) – A Dict of arguments to pass to each menuItem command.

Returns

if the parent menu doesn’t exist then False will be returned, True if successfully attached

Return type

bool

create(**arguments)

Create’s a new popup markingMenu parented to self.parent instance, use :func: MarkingMenu:attach if you need to add to existing markingmenu.

Returns

current instance

Return type

MarkingMenu

kill()

Destroy’s the pop menu from maya.

addCommand(item, parent, radialPosition=None)

Adds the specified command item to the parent menu.

Parameters
  • item (dict) – {“type”: “command”, “id”: “myCustomCommand”}

  • parent (str) – The parent menu string

  • radialPosition (str or None) – The radial position i.e “N”

addSeparator(menu, item=None)

Adds separator to menu

Parameters

menu

show(layout, menu, parent)

Main Method that converts the layout to a maya marking menu.

If implementing a subclass then super must be called.

Parameters
  • layout (Layout) – The layout class to convert

  • menu (str) – The menu fullPath which commands will be attached too.

  • parent (str) – The Parent full Path name.

allowOptionBoxes()
altModifier()
button()
ctrlModifier()
deleteAllItems()
exists()
itemArray()
markingMenu()
numberOfItems()
postMenuCommand(command)
postMenuCommandOnce(state)
shiftModifier()
setShiftModifier(value)
setParent(parent)
setCtrlModifier(value)
setAltModifier(state)
setUseLeftMouseButton()
setUseRightMouseButton()
setUseMiddleMouseButton()
class MarkingMenuDynamic(manager=None)

Bases: zoo.core.plugin.plugin.Plugin

Marking Menu Dynamic allows for subclasses to dynamic generate the marking menu layout.

documentation = 'Marking Menu Dynamic allows for subclasses to dynamic generate the marking menu layout.\n    '
id = ''
execute(layout, arguments)
class MarkingMenuCommand(manager=None)

Bases: zoo.core.plugin.plugin.Plugin

Marking menu plugin which is used to define a single Marking menu action.

Client code should subclass from this command class.

Override the MarkingMenuCommand.execute() method to customize standard left click execution.

Override the MarkingMenuCommand.executeUI() method to customize the option box on the action if the uiData[“optionBox”] is True

documentation = 'Marking menu plugin which is used to define a single Marking menu action.\n\n    Client code should subclass from this command class.\n\n    Override the :meth:`MarkingMenuCommand.execute` method to customize standard\n    left click execution.\n\n    Override the :meth:`MarkingMenuCommand.executeUI` method to customize the option\n    box on the action if the uiData["optionBox"] is True\n\n    '
id = ''
creator = 'Zootools'
static uiData(arguments)

UiData defines the visuals of the command action.

Parameters

arguments (dict) – The global arguments passed to the command from the parent menu.

Returns

Return type

dict

execute(arguments)

The execute method is called when triggering the action item. use executeUI() for a optionBox.

executeUI(arguments)

The executeUI method is called when the user triggering the box icon on the right handle side of the action item.

For this method to be called you must specify in the UIData method “optionBox”: True.