Constraints with python

Hi - I’m currently running some tests with python API and I’ve found a strange problem:


import Blender
from Blender import *

scene = Scene.getCurrent()
empty1 = Object.New('Empty', 'Empty1')
empty2 = Object.New('Empty', 'Target')
empty2.setLocation(1,0,0)

scene.link(empty1)
scene.link(empty2)

empty1.constraints.append(Constraint.Type.TRACKTO)
trackto = empty1.constraints.__getitem__(0)
trackto.__setitem__(Constraint.Settings.TARGET, empty2)

this code seems to work fine except for one thing. When I move the target object the constrainted empty doesn’t react until moved, then it sets up properly. Anyone can explain to me why it’s that way?

have you tried
scene.update(1)

also getitem is the same as constraints[0]