Checking if system operator was overridden with custom

To resolve conflicts between add-ons in Blender, it may be necessary to know if Blender base system operator has been overridden with a custom operator in some third-party add-on.

Note: system operators overriding is enabled only in Blender version 3.4 and above. In Blender 3.5 the ability of overriding system operators was blocked by the developers.

Operator identifier – the value of the bl_idname parameter, which is always specified when defining a custom operator class. It also always follows bpy.ops when calling the operator.

Knowing the operator identifier, we can find out if such an operator has been registered in the Blender Python API.

We can get pointers to all operator modules registered in the API with the following command:

We can get the classes themselves by module pointers:

Looping through all the modules and checking the class identifiers, we can find the required operator:

The base system operators are registered in Blender “out of the box”, and therefore are not listed in bpy.types. This means that if we found a class by identifier, the operator was redefined in a third-party add-on.

Let’s define a function that returns the class of the operator if it has been overridden in add-ons, or None if not.

Code author Andrej

By passing the bl_idname value of the operator being checked into this function as a parameter, we will receive in response either a pointer to its class, if it was redefined in the API, or None – if not.

Complete code with an example of checking the bpy.ops.object.delete operator

The last three lines of code make the check itself.

First, the operator is checked in the initial state of the API (when it has not yet been redefined), so the first time we get a None in response.

Further, by registering an operator with the same identifier bl_idname = “object.delete”, it is force redefined.

A repeated check returns us the operator class, which means that it has been overridden.

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comment
Inline Feedbacks
View all comments