1
$\begingroup$

I've got this code:

            object.location.x += self.parameters.pos_x
            object.location.y += self.parameters.pos_y
            object.location.z += self.parameters.pos_z
            object.rotation_euler = (self.parameters.rot_x, self.parameters.rot_y, self.parameters.rot_z)
            object.select_set(True)
            # Optimization opportunity here
            bpy.ops.object.transform_apply(location=False, rotation=True, scale=False)
            object.select_set(False)

I would like to replace the call to:

bpy.ops.object.transform_apply(location=False, rotation=True, scale=False)

I figured I would have to use the bmesh module in some way, but I cannot figure out how to do this. I want to apply rotation to all objects in a list.

$\endgroup$
4
  • $\begingroup$ You may want to take a look at Bmesh and the mathutils. $\endgroup$ Commented Jun 30, 2021 at 9:36
  • $\begingroup$ Someone closed this as a duplicate, but the proposed solution didn't work for me, which is why I asked the question. In the end I rewrote my code to avoid using rotation_euler. Instead I used bmesh and rotation matrices to perform my rotation directly upon the mesh. I think the question was closed prematurely though. $\endgroup$
    – DrewTNBD
    Commented Jun 30, 2021 at 11:07
  • $\begingroup$ There's also Mesh.transform. $\endgroup$
    – scurest
    Commented Jun 30, 2021 at 13:35
  • $\begingroup$ @scurest closed as a dupe of blender.stackexchange.com/questions/159538/… As it turns out answer required correcting, . Re-opened this one. $\endgroup$
    – batFINGER
    Commented Jun 30, 2021 at 13:40

0

You must log in to answer this question.

Browse other questions tagged .