I try to define five variables (called weights) with Propertygroups and a function to be notified if the Floatporperty-sliders have been moved:
def weightUpdate():
print(f"update----------------------{time.time()}" )
class My_Settings(bpy.types.PropertyGroup):
wgt1: bpy.props.FloatProperty(
name='wgt1',
default=0.0,
update = weightUpdate()
)
wgt2: bpy.props.FloatProperty(
name='wgt2',
default=0.0,
update = weightUpdate()
)
wgt3: bpy.props.FloatProperty(
name='wgt3',
default=0.0,
update = weightUpdate()
)
wgt4: bpy.props.FloatProperty(
name='wgt4',
default=0.0,
update = weightUpdate()
)
wgt5: bpy.props.FloatProperty(
name='wgt5',
default=0.0,
update = weightUpdate()
)
The registration seems to work:
def register():
bpy.utils.register_class(My_Settings)
bpy.types.Scene.my_tool = bpy.props.PointerProperty(type=My_Settings)
And in the draw function of my main addon-class I also could define the slider, even in a loop for all five sliders:
def draw(self, context):
...
for i in range(0,N):
row = layout.row()
wTxt = f"wgt{i+1}"
row.label(text=wTxt)
row = layout.row()
row.prop(my_tool, wTxt)
The problem:
The function weightUpdate is only called when the script is started for the first time. Although any slider change is printed into the Python console in Blender, the function is not called again.
Also, is there a way to pass parameters to the update-function, like update = weightUpdate(3) for the third wgt-slider to identify which slider was changed?