Customize Search

Search allows you to find menus, tools, or commands simply by typing them in a field. You can customize the results displayed when typing in certain search terms by adding your own runtime commands to the results or defining tags to filter the results.

To customize Search preferences

  1. Open the Search field.
  2. Right-click the search field and select Preferences.

    Maya displays the Search preferences window.

  3. Adjust the appropriate preference.

To customize tags

  1. Open the Search field.
  2. Right-click the search field and select Manage Filter Tags.
  3. Click the gear icon in the top-right of the tag window, or right-click to do one of the following:
    • New Tag: Add a new tag
    • Label Color: Change the color of the tag.
    • Rename Tag: Change the name of an existing tag.
    • Delete Tag: Remove an existing tag

Adding new commands

You can add new commands to Search, such as those for 3rd party plug-ins, by using runTimeCommands.

To get a command to appear in Search.

  1. In the Script Editor, create a runTimeCommand with the following flags:
    • -label : The name of the action.

    • -annotation : A short description of what the command does. Search also searches this string.

    • -category : Where in the menu this action can be found eg. Menu items. Common. Edit) - this flag is NOT needed for non menu items.

    • -command : The command to be executed.

    • -plugin : The name of your plug-in if the command is related to one - this will enable us to load your plug-in (if required) before running the command (this will be an app wide option).

    • -image : Optional path to an icon.

    • -url : Optional custom url to external documentation.

    • -tags : Optional tags for your command. Eg. -tags "tag1;tag2".

    • -keywords : Optional keywords to help search results eg. -keywords "ocean; water".

    For example, below is a finished runTimeCommand for a new "Bevel Cube" command, contained in a file named "customCommands.mel":
    runTimeCommand
            -label      "Bevel Cube"
            -annotation "Create a bevelled cube"
            -command    "polyCube; polyBevel"
            -keywords   "chamfer"
            -tags       "Polygon Creation;Polygon Editing;YourStudio"
            bevelCube;
    
    
    Note: If a menu item already exists, you should point it to its existing runTimeCommand to avoid code duplication.
    e.g.
    menuItem -rtc "UnlockNormals";

    This allows the menu item to look up the runTimeCommand UnlockNormals to get its label, annotation, image, and command.

  2. To load your runtime commands alongside your plug-in, add a MAYA_RUNTIME_COMMANDS envar to your plug-in .mod file.

    e.g. MAYA_RUNTIME_COMMANDS=$MAYA_RUNTIME_COMMANDS:/path/to/your/customCommands.mel

    Note: The path should be relative to the plug-in module.
  3. Restart Maya.

    The new runtime command will be sourced when Maya starts up.

Important notes on adding new commands

  • Do not use getPluginResource with runTimeCommands, or else your plug-in will not load when the runTimeCommands are registered.

    Instead, use displayString, or uiRes to get internationalized strings.

    e.g.
    // Register a string resource.  Important: prefix your constants! 
    m_myplugin.kFoo //not just kFoo.
    displayString -value "bar" m_myplugin.kFoo; 
    // Print it using displayString
    print `displayString -query -v "m_myplugin.kFoo"`;
    // Print it using uiRes
    print uiRes("m_myplugin.kFoo"));
  • Try to keep the runTimeCommands MEL file as lean as possible, otherwise it may impact Maya's startup time.
  • If you want items unrelated to a plug-in to show up in Search, you just need to register your runTimeCommand file like you would any other custom menu with Maya (i.e. through userSetup.mel). The database is live, so if at any point during an open Maya session you register a new runTimeCommand, it will be available in Search.
    For example, if you had a script named "userSetup.py" that creates a menu containing special Foo rendering scripts, you would need to convert this:
    cmds.menuItem(p=renderingMenu, l='Submit to Foo', c='import foo_maya;foo_maya.submit_dialog()')
    to this:
    #Create runTimeCommand
    cmds.runTimeCommand('SubmitToFoo', d=True, label='Send to Foo', annotation='Send your scene to Foo for cloud rendering.', category='Menu items.Cloud.Render', 
    command='import foo_maya;foo_maya.submit_dialog()', keywords='render', tags='Render' )
    
    #Create menu
    cmds.menuItem(p=renderingMenu, rtc='SubmitToFoo')
    The "Submit to Foo" script will now show up in Search.

Related topics