Frequent tipster Leonid Nemirovsky sent us a bit of code he just made to help rotate the UCS in AutoCAD.
"First I was doing it manually, but then I wrote this simple code that rotates the UCS on the z-axis between two selected points. It's simple, but I use it a lot."
(defun c:uo ()
(setq pt1 (getpoint " Select First Point: "))
(if (= pt1 nil)(exit))
(setq pt2 (getpoint " Select Second Point: "))
(if (= pt2 nil)(exit))
(command "ucs" "Z" pt1 pt2 "")
Notes from Cadalyst Tip Patrol: Len is right: this code is very simple. It is set up to rotate the UCS about the z-axis. If you need to draw orthogonal lines at a different angle, load this routine, type UO, click a reference point, then click a second point to define the angle — that's it. You can do this manually through the UCS command, but it has a few more steps to it. Just make sure to rotate about the z-axis.