Object transformation apply error

Hi all,

Under 2.90.1, is anybody know why object.transform_apply is not working after an object origin change.

I suppose my context correct with this context filtering:

for ecran in bpy.context.window.screen.areas: 
        if ecran.type == 'VIEW_3D':

Then i browse my objects selection under object mode to get GC coordinates and the Zmax.

s = list(bpy.context.selected_objects)

while i < len(s):
	bpy.context.view_layer.objects.active = s[i]
                object_CG_x = round(bpy.context.scene.cursor.location.x, 3)
                object_CG_y = round(bpy.context.scene.cursor.location.y, 3)
                object_CG_z = round(bpy.context.scene.cursor.location.z, 3)
	        bpy.ops.object.transform_apply(location=True, rotation=True, scale=True)
	        object_Zmax = round(max([j.co.z for j in obj.data.vertices]), 3)

My problem is that the object_Zmax value stored isn’t correct.

On the other hand, when i apply transformations object by object from the python console, the value of object_Zmax is correct.
It’s like the transform_apply is not taking effect or my context not correct.

Is anyone has an idea?

Is it possible you should be using:

bpy.ops.transform.translate(value=(0, 3.88464, 0), orient_type=‘GLOBAL’, orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type=‘GLOBAL’, constraint_axis=(False, True, False), mirror=True, use_proportional_edit=False, proportional_edit_falloff=‘SMOOTH’, proportional_size=1, use_proportional_connected=False, use_proportional_projected=False, release_confirm=True)

Which could be shortened to something like:
v = (2,3,6)
bpy.ops.transform.translate(value=v, constraint_axis=(True, True, True))

thank you for this feedback.
I don’t quite understand the interest of these transformations.
I still tried to insert a null transformation according to a zero vector, as follows,

bpy.ops.transform.translate(value=V, orient_type=‘GLOBAL’, constraint_axis=(Tru, True, True))

but without success.
I continue my research

bpy.ops.transform.translate(value=V, orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(True, True, True))

It appears that there were some syntactical errors. To get around that, go to the console and
type in “bpy.ops.transform.translate(” then hit TAB, you will get the exact format. It is possible to shorten it if you are careful about the brackets. For more information on dealing with console issues and the like, you could probably benefit from the tutorials I have here on youtube https://www.youtube.com/playlist?list=PLPssISxU9GZLU3qYbBPUgDNa3lSv2rSE6 or on my website at https://www.archeuslore.com/blender/blender.html

Thank’s shawn for your return,

I try your transformation with a non null vector (v(2,2,2) or your first one v(2,3,6)), but nothing appears in the 3D view area.

I thought my context management was correct, but i’ in doubt now.

However the interrogation of the objects on their location is correct if the change of the origins is carried out manually before the execution of the script.

The impossibility to change objects origins in this context remains a mystery for the moment for me.

When I tried running the code you had listed, I found that the syntax around the word ‘GLOBAL’ was not right, it had the wrong type of character surrounding it. If you look closely at yours:


and mine:
orient_type=‘GLOBAL’, The difference is in the characters that surround the word GLOBAL. If you are using an alternate keyboard character set, that could be the issue. Better to copy-paste the command, that way you do not pick up any invalid characters.