I am using only objects from photogrammetry and the scale is far from ok when I import them. I would like to be able to scale it automatically on selection if its mesh volume is lower than a precise value.
I tried to do this like below :
def setup_handler():
for h in [x for x in bpy.app.handlers.scene_update_pre]:
if h == scale_function:
bpy.app.handlers.scene_update_pre.remove( scale_function )
bpy.app.handlers.scene_update_pre.append( scale_function )
def scale_function():
if bpy.types.Object.test != scn.objects.active.name :
bpy.types.Object.test = scn.objects.active.name
if bpy.context.mode == 'OBJECT':
volume = volumeDeterminationFunction()
if volume <= 1 :
scale=3
bpy.ops.transform.resize(value=(scale,) * 3, mirror=False, proportional='DISABLED', snap=False, texture_space=False)
I call setup_handler function in a draw function class, but it doesn't work, maybe I should call the function elsewhere ? if you have any idea ? Thanks