4
$\begingroup$

I'm calling one of my operators within another operator. The code worked fine until I tried it on a new file.

search for unknown operator 'MYPLUG_OT_update_list'

I'll try to simplify the code here

class login(bpy.types.Operator):
    bl_idname = "myplug.login"
    bl_label = "Login"

    def execute(self,context):
        ....

        bpy.ops.myplugin.update_list()

        return {'FINISHED'}


class updateList(bpy.types.Operator):
    bl_idname = "myplug.update_list"
    bl_label = "UpdateList"

    def execute(self,context):
        ....
        return {'FINISHED'}

def register():
    bpy.utils.register_module(__name__)


def unregister():
    bpy.utils.unregister_module(__name__)

if __name__ == '__main__':
    register()

Any ideas? I'm debating whether I need to preregister the dependent Operator or call it with some other convention.

$\endgroup$

closed as off-topic by zeffii, user7952, Ray Mairlot, VRM, David Apr 29 '15 at 14:23

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question is too localized in its current form and is unlikely to be applicable outside of a very narrow context. Consider broadening the scope of this question in order to make it more useful for future users of the site." – zeffii, Community, Ray Mairlot, VRM, David
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Are there any errors printed to the system console at registration time? A bad line of code in the operator class can let the registration of that class fail. $\endgroup$ – CoDEmanX Apr 14 '14 at 19:57
  • $\begingroup$ No. No other errors. $\endgroup$ – Ben L Apr 15 '14 at 15:23
  • $\begingroup$ Well, it works fine for me. There must be something wrong, or the example code is different from your actual setup. $\endgroup$ – CoDEmanX Apr 15 '14 at 16:02
  • $\begingroup$ This is impossible to repo. Maybe I did have some other error. $\endgroup$ – Ben L Apr 17 '14 at 19:40
  • $\begingroup$ @BenL still having problem with this ? $\endgroup$ – Chebhou Apr 26 '15 at 23:16
1
$\begingroup$

The message:

search for unknown operator "NAME_TYPE_shortname", "NAME_TYPE_shortname"

could come from the user preferences keyboard shortcuts manager.

  • Registering an incorrectly spelled operator path will give that message.
  • Adding the shortcut in your script before the operator is registered will give that error too.

Maybe this is a typo but your

class updateList(bpy.types.Operator):
    bl_idname = "myplug.update_list"

Would mean that the operator is located at bpy.ops.myplug.update_list(), not bpy.ops.myplugin.*

There is no inherent reason that operators can't be called within other operators, but you will have to wait for the called operator to complete before the calling operator can end, it doesn't fork off into its own thread.

for instance

import bpy

class login(bpy.types.Operator):
    bl_idname = "myplug.login"
    bl_label = "Login"

    def execute(self,context):
        ...

        # bpy.ops.myplug.update_list()  # should be.  
        bpy.ops.myplugin.update_list()

        return {'FINISHED'}


class updateList(bpy.types.Operator):
    bl_idname = "myplug.update_list"
    bl_label = "UpdateList"

    def execute(self,context):
        print('caramba!')
        return {'FINISHED'}

def register():
    bpy.utils.register_module(__name__)


def unregister():
    bpy.utils.unregister_module(__name__)

if __name__ == '__main__':
    register()
    bpy.ops.myplug.login()


# AttributeError: Calling operator "bpy.ops.myplugin.update_list" error, could not be found

If you are calling a set of operators in sequence, then of course you must ensure that the operators are registered globally. If i'm not mistaken the bpy.utils.register_module(__name__) will register classes in order of appearance in the file, use that order to your advantage.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.