Thanks badjo, that's what I was trying to write but I not sure if it will work correctly all the time .
Thanks Stefan,
Can you please explain that function and the way it works ? I can't get it to work but when I added (/ pi 2.0) worked but not as expected and it fails in most cases to give the right rotation as explained in photo above.
atan can take 1 or 2 arguments. For 2 arguments, returns an angle between 0 and 2pi, depending on the sign of the 2 arg. For 1 argument, returns an angle between -pi/2 and pi/2, which is exactly the range of the readable angles.
Use WCS points and entmakex and it should work.
If you use it in a 2D rotated UCS, you need to add UCSXDIR angle. For 3D rotated UCS, you need some more transformation.