;Martin Bielina for CADforum.cz
;(modifications by XANADU)
;rotates selected objects relatively around individual insertion points
;otáčí vybrané objekty relativně kolem jejich vkládacích bodů

(defun C:ROTX ( / i n sel_length ent_sel ent entseznam uhel rotuhel failed) 
(princ "\nSelect objects to rotate") 
(setq ent_sel (ssget '((0 . "INSERT,TEXT,MTEXT,ATTDEF,SHAPE")))  i 0  failed 0)
(if ent_sel
 (progn
  (setq rotuhel (getreal "\nEnter the rotation angle in degrees <180> :")) 
  (if rotuhel 
   (setq rotuhel (* rotuhel (/ pi 180))) 
   (setq rotuhel pi) 
  )     
  (setq sel_length (sslength ent_sel))
  (while (< i sel_length) 
     (setq ent (ssname ent_sel i)) 
     (setq entseznam (entget ent)) 
     (setq uhel (assoc 50 entseznam))
	 (if (or (= (cdr (assoc 72 entseznam)) 5)(= (cdr (assoc 72 entseznam)) 3)) (setq failed (1+ failed)))
     (setq entseznam (subst (cons 50 (+ (cdr uhel) rotuhel)) uhel entseznam)) 
     (entmod entseznam) 
     (entupd ent) 
     (setq i (1+ i)) 
  );while 
));if
(if (> failed 0)(princ (strcat "\n! "(itoa failed) " object(s) not rotated (fit/aligned) !")))
(princ) 
) 