I faced the challenge of straightening an object in space after freezing its transformations. After extensive research and various attempts, I came across an extremely useful MEL-script. Although it’s a bit older, it works wonderfully, and I’d like to share it with you all.
You can find the script here:
https://pastebin.com/aAG9D0hU
Interestingly, even ChatGPT Search didn’t find this post, which shows how well-hidden this solution was
Instructions for use:
1. Copy the entire script into Maya’s MEL editor
2. Run the script
3. In the appearing window, select 3 vertices that are perpendicular to each other
4. Run the script

After execution, the transformation values will be reset and displayed in the Channel Box. This allows you to precisely align the object, even after the original transformations have been frozen.
I hope this script is just as helpful for you as it was for me. It definitely saved me some headaches and greatly improved my workflow in Maya.