I'm writing an add-on and have a float property which drives the thickness attribute of a solidify modifier for the selected object. Currently, the float property displays the last value assigned by the user using that property. Instead, when the user selects an object, I'd like the float property to display the value for that object's solidify modifier.
I've written this function but from what I've read, this won't work anywhere within the draw or poll functions for the panel.
def SyncThickness():
myprops = bpy.data.scenes["Scene"].my_properties
if len(bpy.context.selected_objects) >=1:
myprops.thickness_float = bpy.context.selected_objects[0].modifiers["Solidify"].thickness
else:
myprops.thickness_float = 0
Is there anyway to call this function whenever a different object is selected? Or is a different approach required?
Thanks
Chris