I'm an experienced developer but completely inexperienced with 3d modeling and python.

I have a modeled a Rubik's cube containing 26 (center omitted) cubes where the center cube, if I had one, would be at 0,0,0. When I rotate a face with keyframe animation, all of those 6 cubes report a location of 0,0,0. I think that is because it is reporting their pivot which I have set to the 3d cursor at 0,0,0.

somecube.matrix_local appears to be interesting but the documentation does not say what the return values actually represent and I cannot see the pattern I would expect on the results of adjacent cubes.

All I want to know is how I can find cubes by name on a certain "face" of the Rubik's cube. So all cubes on x = 0 or all cubes on x = 1 or all cubes on x = -1 and likewise for y and z. Or more generally, how do I get the center coordinates of an object that has been animated by keyframes?

If the object has not been animated, the location is obvious but I'm lost once I rotate anything around 0,0,0 which is where I set the 3d cursor.

for reference, cubes (each size of 2) that I would expect to be at (2,2,2) , (2,0,2) and (2,-2,2) show:

>>> ob1.matrix_local
Matrix(((1.0, 0.0, 0.0, 0.0),
        (0.0, 1.0, 0.0, 0.0),
        (0.0, 0.0, 1.0, 0.0),
        (0.0, 0.0, 0.0, 1.0)))

>>> ob7.matrix_local
Matrix(((1.0, 0.0, 0.0, 2.0),
        (0.0, 1.0, 0.0, -2.000000238418579),
        (0.0, 0.0, 1.0, 1.999999761581421),
        (0.0, 0.0, 0.0, 1.0)))

>>> ob4.matrix_local
Matrix(((1.0, 0.0, 0.0, 0.0),
        (0.0, 1.0, 0.0, 0.0),
        (0.0, 0.0, 1.0, 0.0),
        (0.0, 0.0, 0.0, 1.0)))
New contributor
Crowcoder is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

Crowcoder is a new contributor. Be nice, and check out our Code of Conduct.
 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.