0
$\begingroup$

I like to read the location values of an empty by a phyton script. The empty has a shrinkwarp constraint an is projected to an plane (ground).

With >>>

bpy.data.objects['empty_left.005'].location 

i get:

Vector((3.6352062225341797, 5.1430134773254395, 0.0))

but the z-value is the origin value and not the projection value.

If i use the z-value as a variable for a driver, the correct value is used: driver

$\endgroup$
3
  • 1
    $\begingroup$ Could you upload your setup to pasteall.org/blend? $\endgroup$ – p2or Feb 28 '15 at 15:22
  • $\begingroup$ @user2488 just apply the visual transform before reading the values and you will get what you want $\endgroup$ – Chebhou Feb 28 '15 at 17:58
  • $\begingroup$ the empty follow a plane and change its z-value dynamicly, so i cannot apply the transformation! But the answer from pink vertex works fine! $\endgroup$ – user2488 Mar 2 '15 at 9:30
3
$\begingroup$

You can get the location from the world matrix:

empty.matrix_world.translation
$\endgroup$
0
$\begingroup$

you need to apply the visual transform 'which apply the constraint transform' to get the actual location of your object :

import bpy
ob = bpy.data.objects['Empty']
bpy.context.scene.objects.active = ob
bpy.ops.object.visual_transform_apply()
print(ob.location)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.