Getting all classes for menus in Blender UI

To make changes to menus in Blender UI, for example, add new items or overriding the menu completely, we first need to know the class of the menu which we need to change.

Menu class definitions can in some cases be quickly accessed by right-clicking on them, and switching to source code by selecting the “Edit source” in the pop-up menu. However, this method does not work with all menus in the Blender interface.

A complete list of menu classes can be obtained from the bpy.types list.

Let’s define a generator function that, from the entire list of types, will give us classes inherited from the base “menu” type bpy.types.Menu:

The __mro__ tuple provides access to all classes that the current class inherits from. By checking to see if it has the bpy.types.Menu class, we end up with only the classes of the type we need.

Let’s loop through the generated values and display the list of menu classes in the console:

As a result, we got a list of classes with their identifiers:

Once we found the desired identifier in the list, we can use it to modify the Blender menus.

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments