(princ
  "\n飞诗CAD - 块属性编辑 ver1.1 命令：EditAtt 本程序至少要飞诗词库1.1支持！\n"
)
(defun C:EditAtt () (Fs_EditAtt nil))
(defun Fs_EditAtt (ref / a att atts b edit edits i key ref rt showatt)
  (or ref (setq ref (entsel "\n选取图块参考:")))
  (or ref (fsxm-silenceexit))
  (setq atts (fsxm-refatt (car ref)))
  (or atts (fsxm-silenceexit))
  (setq att (car (nentselp (last ref))))
  (cond	((and att (= (fsxm-getendxf att 0) "ATTRIB"))
	 (setq att (assoc (fsxm-getendxf att 2) atts))
	 (setq i (vl-position att atts))
	 (setq rt (list (cons (strcat "k_" (itoa i)) (cadr att))))
	)
  )
  (setq i 0)
  (setq edits nil)
  (foreach att atts
    (setq key (strcat "k_" (itoa i)))
    (setq i (1+ i))
    (setq edit (list ':ed
		     (list 'key key)
		     (list 'label (car att))
		     (list 'value (cadr att))
	       )
    )
    (setq edits (cons edit edits))
  )
  (setq edits (reverse edits))
  (defun showatt (vars	      /		  $key	      a
		  atts	      b		  lastkey     ldcl
		  rt	      txt	  var	      ATTEDIT:DCL:SHOW
		  ATTEDIT:ACT:LIB	  ATTEDIT:ACT:*
		 )
    (setq ldcl '("attedit"
		 (:DIALOG
		  (INITIAL_FOCUS "k_0")
		  (LABEL "飞诗CAD - 块属性编辑 ver1.1")
		  (:TEXT
		   (LABEL "提示：按Alt+A键调用飞诗词库！")
		   (ALIGNMENT CENTERED)
		  )
		  (:COLUMN
		   (FIXED_HEIGHT TRUE)
		   edits
		  )
		  "spacer;"
		  (:button (label "飞诗C&AD词库Ver1.1↑") (key "lib"))
		  "ok_cancel;"
		 )
		 "ed"
		 (:EDIT_BOX (EDIT_WIDTH 50))
		)
    )
    (defun attedit:act:* ()
      (if (wcmatch $key "k_*")
	(setq lastkey $key)
      )
    )
    (defun attedit:act:lib ()
      (setq var (get_tile lastkey))
      (setq vars (getallkeyvar))
      (return "lib")
    )
    (defun attedit:dcl:show ()
      (foreach a vars (set_tile (car a) (cdr a)))
      (mode_tile (car (last vars)) 2)
    )
    (setq rt (fsxm-ldcl ldcl "attedit"))
    (cond ((= rt "lib")
	   (cond (fs_txtlib)
		 (t
		  (fstl_load_files
		    (fstl_getcanload (fstl_findcmd "fs_txtlib"))
		  )
		 )
	   )
	   (setq txt (car (fs_txtlib var "0")))
	   (setq vars (append vars (list (cons lastkey txt))))
	   (showatt vars)
	  )
	  ((null rt) nil)
	  (t (reverse rt))
    )
  )
  (mapcar '(lambda (a b) (fsxm-setendxf (last a) 1 (cdr b)))
	  atts
	  (showatt rt)
  )
  (entupd (car ref))
  (princ)
)