Hi,
As far as I understand what you want to do, The problem is that pt1 and pt2 coordinates are defined in your first UCS and the rectangle is drawn in the second one.
If you want to use pt1 and pt2 to draw the rectangle, their coordinates have to be translanted in this UCS.
A way to do this is to to translate pt1 and pt2 UCS coordinates to WCS coordinates, then, after UCS have been changed translate them to the new UCS.
(defun C:ar1 (/ obj pt1 pt2 pt11 pt22 pt4-temp pt3)
(setvar "osmode" 35)
(setvar "cmdecho" 0)
(command "_.ucs" "_w")
(command "_.ucs" "x" "90")
(setq pt1 (getpoint "\n first : "))
(setq pt2 (getpoint pt1 "\n second : "))
;; Translate points from current UCS to WCS
(setq pt11 (trans pt1 1 0))
(setq pt22 (trans pt2 1 0))
(setq pt4-temp (polar pt1 (/ pi 2) 50))
(setvar "osmode" 0)
(vl-cmdf "_.UCS" "_3" pt1 pt2 pt4-temp)
;; Translate points from WCS to the new current UCS
(setq pt1 (trans pt11 0 1))
(setq pt2 (trans pt22 0 1))
(setq pt3 (polar pt2 (/ pi 2) 500))
(command "rectangle" pt1 pt3)
)