1

My greetings to the community.

I have a specific task which i have managed to perform using python. I need to do the same task faster and i believe i found a way but i need some help with that. My problem is the lack of understanding of the problem in 3d-space and more specifically the matrix transformations in local/global coordinates.

I have an object which i need to move in a specific direction by 1cm in local coordinates. the lower object in the figure is the original position and the upper is the target position. therefoer the movement is towards Z in local coordinates.

enter image description here

What i do is:

new_location = Vector((0, 0, 1)) # move by 1cm in the Z-direction
trans = Matrix.Translation(new_location)  # create transformation matrix
object.matrix_world @= trans 
mat = object.matrix_world
verts = [mat @ v.co for v in object.data.vertices]

This works just fine but it is slow due to the translation of each vertice in the last loop.

I think i can do the same (correct me if i'm wrong) using bpy.ops.transform.translate. something like this:

bpy.ops.transform.translate(value=(0, 0, 1), orient_type='LOCAL',
                            orient_matrix=((1, 0, 0), (0, 1, 0), (0, 1, 0)), orient_matrix_type='LOCAL',
                            mirror=True, use_proportional_edit=False, proportional_edit_falloff='SMOOTH',
                            proportional_size=1, use_proportional_connected=False,
                            use_proportional_projected=False, release_confirm=True)

but what i can't figure out the correct values of "value" and "orient_matrix".

thanks in advance

0 Answers0