Why does an update function loop when string property is reset?

by Way2Close   Last Updated August 10, 2018 07:15 AM

I have a string property, when it is updated it runs a function which runs an operator, the operator clears the string at the end to reset it. This makes the function (string_update) loop to infinite recursion. As I understand, order of events should be:

update string run function once run operator finish

What am I missing?

import bpy


def string_update(self, context):
    bpy.ops.test.test()
    print("Ran")
    return None


class test_vars(bpy.types.PropertyGroup):
    test_update_string = bpy.props.StringProperty(
        name = "",
        default = "",
        update = string_update
        )


class Test_Op(bpy.types.Operator):
    """"""
    bl_idname = "test.test"
    bl_label = "test"

    def execute(self, context):
        bpy.context.scene.test_vars.test_update_string = ""

        return {'FINISHED'}


def register():
    bpy.utils.register_module(__name__)
    bpy.types.Scene.test_vars = bpy.props.PointerProperty(type = test_vars)


def unregister():
    bpy.utils.unregister_module(__name__)
    bpy.utils.unregister_class(test_vars)
    del bpy.types.Scene.test_vars
Tags : python


Related Questions


Ipodtouch Jail-Break aid?

Updated March 26, 2015 07:30 AM


Python: Methods to multiply/divide vectors

Updated March 27, 2015 14:20 PM

Adding sliders from UI to pie menu

Updated April 19, 2015 22:09 PM