I want to execute a function everytime the cursor has been moved. Is there a callback function that I can use for this? I tried bpy.app.handlers.scene_update_post but this doesn’t seem to work. Any tips?
Thanks,
Marty
I want to execute a function everytime the cursor has been moved. Is there a callback function that I can use for this? I tried bpy.app.handlers.scene_update_post but this doesn’t seem to work. Any tips?
Thanks,
Marty
I’d go for a scene update handler or modal timer op. My tip is post your code.
did you try this?
if event.type == 'MOUSEMOVE':
#do this
return {'RUNNING_MODAL'}
Why not just change the key binding to a custom operator, which calls the original operator?
So I want to display the coordinates of the 3d cursor in waxholm space (an anatomical space for the brain). I tried this here
def waxholm_coordinates(scene): loc = scene.cursor_location
wx = 268 - loc.x / f
wy = 623 + loc.y / f
wz = 248 + loc.z / f
print("%i, %i, %i" % (wx, wy, wz))
return Vector((wx, wy, wz))
bpy.app.handlers.scene_update_post.append(waxholm_coordinates)
which works, but the command line runs full. The command is basically executed every fraction of a second. So I was wondering whether there is a way to execute this function only when cursor was moved.
@Albertofx: how do you do that? where do you get event.type from?
@CoDEmanX: can you do that with the 3d cursor? I looked at bpy.data.window_managers[0].keyconfigs but could not find anything
Thanks already for your support.
User preferences, input, search for “set 3d cursor”
you can change it programmatically too of course, see e.g.
http://www.blender.org/api/blender_python_api_2_75_release/info_tutorial_addon.html#keymap