(DEFUN C:MLLA ( / )
  (prompt "/nSelect multileaders: ")
  (if (setq ss (ssget ":L" '((0 . "MULTILEADER")))); IF anything is found when to makes a selection of mleaders
    (progn ; THEN
      (setq mlent (entsel "/nSelect multileader to align to: "); prompt user to select mleader to align others to
            ed (entget (car mlent)); store entity data for selected mleader
            txxpt(cadr(assoc 12 ed)); store x point for text insertion
            dlxpt(cadr (assoc 10 (member '(302 . "LEADER{") ed))); store x point for dogleg object
            entqty (sslength ss); store quantity of mleaders selected
            cnt 0); set counter to 0
      (while (< cnt entqty); while there are still mleaders in list
	(setq mlent (ssname ss cnt); store entity name (starting with the first mleader)
	      ed (entget mlent); store entity definition

	      old_txxpt (assoc 12 ed); store entities text object point data
	      new_txxpt (cons txxpt (cddr old_txxpt)); create new text object point data utilizing x point from mleader to align to
	      ed (subst (cons 12 new_txxpt) old_txxpt ed); swap old text object point data for new in entity record

	     old_tfxpt (assoc 10 ed); store entities text frame object point data
	     x-diff (- (- (cadr old_txxpt) txxpt)); find delta-x between current ent and selected alignment mleader
	     newx (+ x-diff (cadr old_tfxpt)); create new x point coordinate for text frame object
	     new_tfxpt (cons newx (cddr old_tfxpt)); create new text object point data utilizing newly created x point
	     ed (subst (cons 10 new_tfxpt) old_tfxpt ed); swap old text frame object point data for new in entity record

	     old_dlxpt (assoc 10 (member '(302 . "LEADER{") ed)); store entities dogleg object point data
	     new_dlxpt (cons dlxpt (cddr old_dlxpt)); create new dogleg object point data utilizing x point from mleader to align to
	     ed (subst (cons 10 new_dlxpt) old_dlxpt ed)); swap old dogleg object point data for new in entity record
	(entmod ed); write new data to database
	
	(setq cnt (1+ cnt)); set counter to advance to the next entity in selection set
       ); end WHILE
     ); end THEN
    ); end IF (no ELSE statement specified)
  (princ); exit quietly
  )
(princ); load clean
