I am having a little confusion here. Some background: the user perspective faces in a direction, I am trying to make a box that faces the user perspective. That I have been able to achieve (pic below)
Side view after creation, arrow shows perspective view:
User perspective on creation:
Where the red arrow is the normal view of the user perspective - all good.
The problem is when I try to resize the box into a rectangle, as you can see the transform coordinate does not align well on creation of the cube. I get something like this:
Here is the code I have come up with so far:
world_view = bpy.context.space_data.region_3d.view_rotation local_view = Model_hollow.matrix_world.inverted().to_quaternion() @ world_view view3d_rot_matrix = local_view.to_matrix().to_4x4() bpy.ops.mesh.primitive_cube_add() cut_box = bpy.context.object cut_box.name = 'cut_box' bpy.ops.object.select_all(action="DESELECT") cut_box.select_set(True) bpy.context.view_layer.objects.active = cut_box cut_box.location = Model_hollow.location bb = Model_hollow.bound_box dx_local = max(bb[i] for i in range(8)) - min(bb[i] for i in range(8)) dy_local = max(bb[i] for i in range(8)) - min(bb[i] for i in range(8)) bpy.ops.transform.resize(value=(dx_local, dy_local, 1), orient_matrix=view3d_rot_matrix.to_3x3()) cut_box.data.transform(view3d_rot_matrix) cut_box.data.update()
I do supply the orientation matrix.