5
$\begingroup$

When creating a new Blender Operator, you'll derive the class from bpy.types.Operator, like this:

import bpy

class MyShinyOp(bpy.types.Operator):
    bl_idname = 'object.my_shiny_operator'
    bl_label = "Operator"

   # ... and so on and so forth

My current understanding is that most operators should derive from bpy.types.Operator just like above. After registration, I should see this operator as

bpy.types.OBJECT_OT_my_shiny_operator

But what if I want to extend an already existing one, like

bpy.types.MESH_OT_primitive_monkey_add

I cannot derive from it, as it isn't a class any more, it is a registered Operator - a class instance. So this code will fail:

class MyShinyOp(bpy.types.MESH_OT_primitive_monkey_add)

Is there a way to get a reference to the class itself? Is it around somewhere just like user written classes? Or is this somehow wrapped C++ stuff? Is it possible to derive from existing Operators at all?

$\endgroup$
3
  • $\begingroup$ @zeffii I do have the mentioned operator available, it's coming from a plugin. Honestly it doesn't matter which one, I'm asking this as a generic question. I'd be interested if this can be done at all, as it would allow to customize Blender further in a very elegant way. $\endgroup$
    – aliasguru
    Oct 9, 2016 at 16:05
  • $\begingroup$ If you have the addon for that operator, then from that_addon import thatoperator is your best bet. $\endgroup$
    – batFINGER
    Oct 10, 2016 at 13:31
  • 1
    $\begingroup$ @batFINGER thanks, I was aware of that, but how would I go about, let's say, bpy.types.MESH_OT_primitive_monkey_add ? I don't know where to find the source file for that to check what classes are available. Still it would be nice to be able to extend said operator. $\endgroup$
    – aliasguru
    Oct 10, 2016 at 16:35

0

You must log in to answer this question.

Browse other questions tagged .