I have a model that I initially started to create not exactly along the axes. I need to rotate it so that the faces go exactly along the axes. And you also need to find out the angle of rotation of the model relative to the position when it will look exactly along the axes. Is it possible to do this ? I twisted the model in every possible way, but nothing brought results.
- In Edit Mode, select an element aligned to your desired axes, and Header > Transform Orientations > Create a Transform Orientation from the element, by clicking the little '+' in the pop-up.
- In Object Mode, set the Header > Options to affect only 'Origins'
- With the object selected, Header > Transform > Align to Transform Orientation.
Now the axes will be aligned to the selected element. Uncheck the 'Origins' option.
Before straightening the object, (AltR) you will be able to read the old rotation from the N panel > Item > Transform > Rotation fields. (Perhaps stash that rotation on a copy)
Presuming that the object's rotation is applied so that Clear Rotation with Alt+R doesn't work, there are probably smart ways to find out the angle of rotation your object is off the axes - but I forgot them (but while I was preparing my answer I saw that @joshsanfelici already provided a good one).
Another way you could get the angle is the following (this method is in case your plane is just rotated on the Z axis and flat in XY): in Edit Mode, select some of those edges of which you want to know the angle.
While still using Global orientation, press E Z to extrude them (up or down doesn't matter) constrained to the Z axis.
Add a new object, preferably one with rectangular sides like a cube. Make sure the Snapping options are set to Face Project and Align Rotation to Target.
Select the cube. Since you only need the Z rotation, lock X and Y rotation in the sidepanel to avoid weird rotations of the cube. Press G to move it towards the extruded faces. With either the Snap tool enabled (the magnet symbol left to the Snapping options) or holding Ctrl for temporary snapping make sure the cube snaps to the new faces.
After confirming the new position of the cube with left-click, the Z rotation of the cube shows the angle to which your mesh is rotated off the global axes.
In my case it showed -16.4° but of course there can be decimal places that might just be shown rounded. The best is to copy the value from the input field to get the exact angle.
Now select your mesh, go to Edit Mode, select all with A, then press R Z to constrain rotation to the Z axis, paste the angle with Ctrl+V followed by minus to reverse whatever value it was and hit Enter. Now your mesh is aligned to the global axes.
If you can apply object's transforms, You could go to edit mode, select some mesh elements that have normals in the orientation you would like to match the axis, make Custom Transform Orientation out of them, go to object mode and run
C.object.matrix_world = C.scene.transform_orientation_slots.custom_orientation.matrix.to_4x4().inverted() in Python Console.
I assume that in object mode the model has a straight orientation, so you have to rotate it to align straight lines with the 3D world.
There are many ways you can choose to perform the task, I would use bones.
Go to edit mode, select a vertex belonging to a straight line, press Shift S > Cursor to selected.
Back in object mode press Shift A > Add Armature > Single bone.
In the Armature Edit mode, turn on vertex snapping and snap the tail of the bone to another vertex of the straight line.
With the bone selected in its edit mode, press E, Y, move the mouse, Enter, to extrude a new bone aligned with the Y world axis.
Set the roll of both bones to 0.
Back in Object mode, select the model, Shift select the armature, go to pose mode, select the oblique bone and press Ctrl P > Bone, to parent the mesh to the rotated bone.
Set the rotation mode of the bones to "Euler XYZ".
Select the straight, bone, Shift select the rotated bone, press Shift Ctrl C > Add Copy Rotation bone constraint.
In the bone constraints panel Apply the copy rot constraints.
Back in object mode, select the mesh and press Alt P > Keep transform, then delete the armature object.
In the "N" properties panel you can read the exact value of the rotations involved in the process (in my example 0,0,7.47059 degrees).
If you press then Ctrl A > Apply all transform, you will end up with an aligned model with all its transform values resetted (000, 000, 111).