Can't get location of object when using CopyLocation constraint

Hi All,

I’m trying to get the location of an object that is using a CopyLocation constraint (using blender 2.8)

I’m gradually adjusting the influence and want to get its location as it moves using python, however the location is always reading as the objects start location (in this case (0,0,0)

Any ideas will be much appreciated.

Thanks!

A

Hi a_vb_0

You probably have already solved this, but this is what I did.

I just starting to learn how to use Python for rigging, and I actually came across this issue a couple of days ago while figuring out a foot rig for my auto rigger.

Something like this seems to work, take the matrix of object, it seems to contain values after constraints, then take the position/location part from there:

import bpy
import mathutils
import math

# get position after constraint (cube has position constraint)
m = bpy.data.objects["Cube"].matrix_world

# get position from matrix
pos = m.translation

# third object for testing
bpy.data.objects["axis"].location = pos

Not sure if this is the recommended way to do this, but it worked so far for me.