; MVTXT.LSP
;
; Lyn Russell for Autograf Utilities, Feb 1990.
;
; Assumptions
;   1. The last non-deleted entity in the database is the TEXT in question.
;   2. System variable USERR1 contains the correct displacement value.
;
; get the last entity (it should be text)
; do a MOVE command using the text's start point as the base point
; get text's rotation value (stored in radians)
; convert angle to degrees and add 90 to it
; get a displacement value from the USER1 global variable
; the second point of the move is @ displacement < rotation+90


(defun mvtxt2 ( / ent ang disp)
  (setvar "cmdecho" 0)

  (setq ent (entget (entlast)))		; get the TEXT entity's data list

  (if (/= (dxf 0 ent) "TEXT")
    (prompt "\nError: the last entity is not TEXT\n")
	(progn
      (command "move" "l" "")
      (command (dxf 10 ent))
      (setq ang (+ (atof (angtos (dxf 50 ent) 0 2)) 90.0))
      (if (= (setq disp (getvar "userr1")) 0.0)
        (prompt "\Warning: displacement value = 0\n")
      )
      (command (strcat "@" (rtos disp 2 2) "<" (rtos ang 2 2)))
    )
  )

  (setvar "cmdecho" 1)
  (princ)
)

; DXF takes an integer dxf code and an entity data list.
; It returns the data element of the association pair.

(defun dxf (code elist)
  (cdr (assoc code elist))
)
