3

Is it possible to access operator's class for builtin operators?

For addons, I can either import them from addon's module from node_wrangler.operators import NWLazyMix or from bpy.types -> bpy.types.NODE_OT_nw_lazy_mix.

I wanted to use operator's class to override .execute or modal to have a general solution to solve issues like this and this.

FamousSnake
  • 416
  • 2
  • 11

1 Answers1

2

No Idea, how to access the class, but if the operator is written in Python, you can find its code. There is a bunch of operators in Blender's installation folder(on Windows they are at C:\Program Files\Blender Foundation\Blender 4.0\4.0\scripts\startup\bl_operators) So you can just copy the code defining the operator, change it and register it again. This works as we see from the tooltip that I changed for Select Camera operator:

enter image description here

If the operator is not written in Python, it seems it's no longer possible to override it this way in recent versions:

enter image description here

That's what happens if I try to register an operator with mesh.primitive_cube_add bl_idname.

It used to be possible in previous versions and was useful in some cases. You can still write a new operator entirely and change the UI and keymap to replace some operator, but that's a lot of work.

Martynas Žiemys
  • 24,274
  • 2
  • 34
  • 77