0
$\begingroup$

I want to call a method of an operator when a scene property has changed.

I know there is an update callback:

bpy.types.Scene.h_dock = bpy.props.EnumProperty(
    items = h_dock, name="Dock", 
    description="Dock to left or right side", 
    default="0", update=???)

But how to add a method of an operator here or any other class/instance in which I have to update member variables?

Thx

$\endgroup$
0
$\begingroup$

here is how i did it in my addon, i registerd my property's in directly in the register def and made a def at the top of my script that gets called when the value of the property changes

def Update_BoolProp(self, context):
    pass
bpy.types.Object.BoolProp = bpy.props.BoolProperty(
    name="BoolProp",
    description="description",
    default = True,
    update = Update_BoolProp
    )

i think that you can define the update function where ever you like as long as you can access where you define your property's.

ps: your vids are really helpful

| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ Cheers. Unfortunately now you have turned it into a recursion loop, by updating the property in its own update method. A good way to toggle bools is flag = not flag $\endgroup$ – batFINGER Mar 15 '19 at 10:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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