简体   繁体   中英

How to invoke/execute Maya menu item using Python?

I would like to learn how to invoke/trigger a menu bar item in Maya using python.

For example, opening the "content browser" dialog window from menu bar:Windows->General Editors->Content Browser.

Appreciate any hints on this! Thank you!

If you enable "Echo all commands" in the script editor, you can see which commands are executed if you choose a menu item, in this case it is:

OpenContentBrowser;

So from python you can try it with pymel:

import pymel.core as pm
pm.mel.OpenContentBrowser()

Or with cmds:

import maya.cmds as cmds
cmds.OpenContentBrowser()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM