 ; Remove the rotation from an entity. (Block or Text)
 ; Copyright 1990, 1997 By Rocket Software Ltd.
 ; Another program that seemed to need to be written.


 ; Drot - added program - derotate entities,
 ; ignore attributes.
 (defun C:DROT ( / un ss num lll lln typ ra)
  (setvar "cmdecho" 0)
  (command "undo" "mark")
  (prompt "Select entities to derotate: ")
  (setq ss (ssget))
  (setq num 0)
  (while (ssname ss 0)
         (setq lll (ssname ss 0))
         (setq lln (entget lll))
         (if (setq ra (assoc 50 lln))
             (progn
                  (setq num (1+ num))
                  (entmod (subst (cons 50 0) ra lln)))
             (setq un (if un (1+ un) 1)))
         (ssdel lll ss))
  (setq typ (strcat "Entities derotated: " (itoa num)))
  (prompt (if un (strcat typ ", untouched: " (itoa un)) typ))
 (princ))


 ; Derot derotate entities with the rotate command, this
 ; catching attributes.
 (DEFUN C:DEROT ( / un ss num lll lln typ ra)
  (setvar "cmdecho" 0)
  (command "undo" "mark")
  (prompt "Select entities to derotate: ")
  (setq ss (ssget))
  (setq num 0)
  (while (setq enam (ssname ss num))
         (setq num (1+ num))
         (setq entt (entget enam))
         (if (setq ra (cdr (assoc 50 entt)))
             (progn
                  (setq pa (cdr (assoc 10 entt)))
                  (setq rotang (- (/ (* 180 ra) pi)))
                  (command ".rotate" enam "" pa rotang))
             (setq un (if un (1+ un) 1))))
  (setq typ (strcat "Entities derotated: " (itoa num)))
  (prompt (if un (strcat typ ", untouched: " (itoa un)) typ))
 (princ))

(prompt "C:DROT/C:DEROT")
(princ)