Hi all,
I have an object O which is a child. I want to put an empty in O. I don’t wont the empty to be the child of anything thus I need the global coordinates of O.
First unsuccessful try:
Moving the 3D cursor to the object and read the coordinates of the 3D cursor. But there is a poll exception when I try to move the 3d cursor with the snap_cursor_to_active() because of an unappropriate context.
Second unsuccessful try:
Using the matrices. But the code below with Blender 2.63 shows that the matrices are unreliable. The 2 empties a and b are at the same global position but the matrices are completly different depending on whether the empty is defined using a location or a translation. Moreover the identity
matrix_local = matrix_parent_inverse x matrix_basis
is not true, in contradiction with the claim I found here http://wiki.blender.org/index.php/User:Pepribal/Ref/Appendices/ParentInverse
So my question is : what is the reliable way to get the global coordinate of an object.
bpy.ops.object.add(type='EMPTY')
a=bpy.context.object
a.location=Vector((1,2,3))
bpy.context.scene.update
print ("Matrice A")
print ("matrix_basis")
print(a.matrix_basis)
print ("matrix_local")
print(a.matrix_local)
print ("matrix_parent_inverse")
print(a.matrix_parent_inverse)
print ("matrix_world")
print(a.matrix_world)
print ("Matrice B")
bpy.ops.object.add(type='EMPTY')
b=bpy.context.object
bpy.ops.transform.translate(value=Vector((1,2,3)))
bpy.context.scene.update
print ("matrix_basis")
print(b.matrix_basis)
print ("matrix_local")
print(b.matrix_local)
print ("matrix_parent_inverse")
print(b.matrix_parent_inverse)
print ("matrix_world")
print(b.matrix_world)