Location of object relative to median point?

Hi Guys,

A bit simpler I have an object with an empty offset from it parented to the object.

I need to calculate the distance from the object center to the empty is on a specific local axis?

but when parenting the empty to the object its coordinates match the objects coordinates?

does that make sense?

how can I find the distance of the object in local terms.

ie

bpy.data.objects[‘myObject’].location.x = 0.0
bpy.data.objects[‘myObject’].location.x = 0.0 ! actuall the empty is offset by 1.0???

I solved my problem but still lack a solution? There is an offset appearing I was just checking the wrong axis. I noticed that there was an x offset of 0.6 and of course the y axis and z axis would not change as I rotate the parent object as the local coordinates move with the parent.

So where I was expecting the y and z axis to change values of course it will not because it is still locally at the same coordinates from the parent despite what angle of rotation the parent object is in.

The only way it works is if I take the world coordinates for the empty and the parent then do the calculations based on those values.

Just for info I am trying to do a Piston and crank animation without using bones using Pythagoras theorem to calculate positions but it needs to work so that if I move the whole train that everything still animates correctly.

seemed like a simple project at first but became rapidly complicated and the aim was to create a generic script that would work for multiple projects based on values input as parameters.

Though I am someone ‘THICK’ in the math department. Maybe this is currently beyond my capability.