How to refresh / update the 3D View during runtime (LEAP MOTION PROJECT)

I’m working on an addon for the Leap Motion Controller and need to know how to update the 3d view during script runtime. The leap motion is tracking a hand’s position and outputs a 3d position via (X,Y,Z) coordinates. I can get the cube to move, but it only goes to the last hand position when I stop the script. How can I make the cube continuously move?

Is it something where I need to call a new draw function or an update or what? I’ve spent 3 hours on the api site and came up empty.

I’m currently using this code to modify the cube’s position. Am I doing it wrong?["Cube"].location = (p.x/10, p.y/10, p.z/10)

Thanks for all your help- Andy

You need to use a modal operator. Modal operators are the only way to get the viewport/3d view updated as long as the script is still running.

you could try registering your action with a scene update handler :

#define action
def Action(Scene):
do stuff here

#register action

To get it to work properly you’d need to have the device driver send update events internally through C code… or just run it as an animation (Alt+A) while you’re testing.

Blender only updates when it receives external input, mouse moves &etc (or at least that’s how it used to work, haven’t messed with it lately).

Have you tried calling the tag_redraw method of the viewport?

Can you give some details on how you got Leap Motion Unit to work in Blender? I have been unsuccessful in getting started.