5
$\begingroup$

I'm trying to get invoke_props_popup to work. But my code produces this error:

Error: Operator 'OBJECT_OT_keyframe_changer' does not have register enabled, incorrect invoke function

Traceback <most recet call last):
    File "(Script-path)", line 63, in <module> ...

RuntimeError: Error: Operator 'OBJECT_OT_keyframe_changer' does not have register enabled, incorrect invoke function

Line 63 is bpy.ops.object.keyframe_changer('INVOKE_DEFAULT')

I haven't been able to find any documentation to help me with this. Why does it not run? Why does it give me an error?


This is the code I have so far:

class KeyframeChangerOperator(bpy.types.Operator):
    """Let's you change keyframe position"""
    bl_idname = "object.keyframe_changer"
    bl_label = "Keyframe changer"
    my_float = bpy.props.FloatProperty(name="Keyframe position")


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

    def invoke(self, context, event):
        wm = context.window_manager
        return wm.invoke_props_popup(self, event)

def register():
    bpy.utils.register_class(KeyframeChangerOperator)

def unregister():
    bpy.utils.unregister_class(KeyframeChangerOperator)


if __name__ == "__main__":
    register()

    # test call
    bpy.ops.object.keyframe_changer('INVOKE_DEFAULT')
$\endgroup$
3
  • 1
    $\begingroup$ invoke should return: "return wm.invoke_popup(self)", let me know if this works for you. $\endgroup$
    – p2or
    Commented Jan 29, 2015 at 18:10
  • $\begingroup$ That worked. Got the script running. Thanks. I was under the impression though, that using invoke_popup would update the float_property everytime the prop is changed. As opposed to dialog, which only updates it when you click OK. Was I wrong to assume that? $\endgroup$
    – Humilton
    Commented Jan 29, 2015 at 18:17
  • 1
    $\begingroup$ You can also use "invoke_props_popup", but then you also have to set "bl_options". $\endgroup$
    – p2or
    Commented Jan 29, 2015 at 19:04

1 Answer 1

7
$\begingroup$

You simply forgot to set bl_options:

import bpy

def set_keyframe_position(flt):
    print (flt)

class KeyframeChangerOperator(bpy.types.Operator):
    """Let's you change keyframe position"""
    bl_idname = "object.keyframe_changer"
    bl_label = "Keyframe changer"
    bl_options = {'REGISTER', 'UNDO'}

    my_float = bpy.props.FloatProperty(name="Keyframe position")

    def invoke(self, context, event):
        return context.window_manager.invoke_props_popup(self, event)

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

def register():
    bpy.utils.register_class(KeyframeChangerOperator)


def unregister():
    bpy.utils.unregister_class(KeyframeChangerOperator)


if __name__ == "__main__":
    register()

    # test call
    bpy.ops.object.keyframe_changer('INVOKE_DEFAULT')
$\endgroup$
1
  • 1
    $\begingroup$ Dude. I. Love. You. $\endgroup$
    – Humilton
    Commented Jan 29, 2015 at 19:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .