But if for some reason you want to keep the current behavior and change the orientation at the end, the code could be like this:
(defun c:TY (/)
(setq old_err *error*)
(defun *error* (a /)
(princ "")
(setq *error* old_err)
(princ)
)
(setvar "cmdecho" 0)
(vl-load-com)
(setq VlaObjLine
(vlax-ename->vla-object
(car (entsel "Selecciona una linea : "))
)
)
(setq LinAngle (vla-get-Angle VlaObjLine))
;;; (if (and (< LinAngle 4.71239) (> LinAngle 1.5708))
;;; (setq LinAngle (+ LinAngle PI))
;;; )
(while (setq VlaObjText
(vlax-ename->vla-object
(car (entsel "Selecciona un texto : "))
)
)
(vla-put-Rotation VlaObjText LinAngle)
(while (not (member (setq cambiar? (strcase (getstring "\n¿Rotar el texto? <No>/Si: "))) '("" "N" "NO" "S" "SI")))
(princ "\nOpcion seleccionada no valida. Repite, por favor...")
)
(if (member cambiar? '("S" "SI"))
(vla-put-Rotation VlaObjText (+ LinAngle PI))
)
(vlax-release-object VlaObjText)
)
(vlax-release-object VlaObjLine)
(setvar "cmdecho" 1)
(princ)
)