Transform values after parenting an object

There’s something really basic I’m not understanding about an object’s transform after it’s made a child of another object. Here’s an simple example of what I’m not getting:

I have an object “Parent” at position (10,0,0) and a “Child” at (15,0,0), both with no rotation or scaling. When I make Parent the parent of Child I would expect Child to be at position (5,0,0) in Parent’s coordinate system, but Blender says it’s still at (15,0,0). And when I move Parent, Child moves with it, but Blender still says Child’s position is (15,0,0).

How does that make any sense, and how can I find Child’s position?

child object should be at (-5,0,0) in parent object space, not +5.

What’s wrong about your assumption is, that object locations aren’t relative coordinates, but absolute. It doesn’t matter whether an object is parented or not, Object.location will always be the location in world space.

If you need to know the relative location, use this:

Object.matrix_local.translation

e.g.

>>> bpy.data.objects['Cube.001'].matrix_local.translation
Vector((-4.999998092651367, 0.0, 0.0))
# rounded --> (-5,0,0)

Seems unintuitive, but I can work with that. Thanks.

(And it is +5 in parent space, not -5. I think you misread my first post.)