i am wondering if it is possible, to execute a function if the user changes a custom property of an object?

For example, i create a custom property "MyInt" for every selectable object in the scene. This property defines the rotation of the object from the center point. If the user now changes the property i want the object to spin around the center. For that reason i would like to know if it is possible to react to a "property-change" event and move the object accordingly to the property value?

My code:

import bpy
from bpy.props import *

bpy.types.Object.MyInt = FloatProperty(
    name="Rotation in °",
    min = -180.0, max= 180.0,
    default = 0)

class Panel(bpy.types.Panel):
    bl_label = "Object Rotation"
    bl_space_type = "PROPERTIES"
    bl_region_type = "WINDOW"
    bl_context = "render"

    def draw(self,context):
        layout = self.layout
        col = layout.column()
        col.prop(context.active_object, "MyInt")

def register():
def unregister():
if __name__ == '__main__':
  • $\begingroup$ Yes you are right, that solved the problem. Thank you very much! $\endgroup$ Apr 8, 2016 at 20:24


Browse other questions tagged .