(defun fs_aedit	(cmd	     /		 lst	     ss
		 *ERROR*     FS_UP_ENSS	 FS_ED_UPPT  FS_ED_GETENSS
		 FS_PTONENP  FS_AEDIT
		)
  ;;点在线上?
  (defun fs_ptonenP (en pt)
    (equal (vlax-curve-getclosestpointto en pt) pt 1e-6)
  )
  ;;取图元的关联数据
  (defun fs_ed_getenss
	 (en / box b1 b2 enep enptlst ensp en_e en_s ep obj sp ss)
    (setq obj (vlax-ename->vla-object en))
    ;;在en周围的东东
    (setq box (fsxm-obj-box obj))
    (setq b1 (trans (car box) 0 1))
    (setq b2 (trans (cadr box) 0 1))
    (setq ss (ssget "C" b1 b2 '((0 . "line,arc,circle,ellipse"))))
    ;;en的起点
    (setq ensp (vlax-curve-getStartPoint en))
    ;;en的终点
    (setq enep (vlax-curve-getendPoint en))
    ;;与en有关的图元
    (ssdel en ss)
    (foreach a (fsxm-ss->enlist ss)
      ;;起点在en上的图元
      (setq sp (vlax-curve-getStartPoint a))
      (if (fs_ptonenP en sp)
	(setq enptlst (cons (list a sp) enptlst))
      )
      ;;终点在en上的图元
      (setq ep (vlax-curve-getendPoint a))
      (if (fs_ptonenP en ep)
	(setq enptlst (cons (list a ep) enptlst))
      )
      ;;en的起点所在图元en_s
      (if (fs_ptonenP a ensp)
	(setq en_s a)
      )
      ;;en的终点所在图元en_e
      (if (fs_ptonenP a enep)
	(setq en_e a)
      )
    )
    (list en en_s en_e enptlst)
  )
  ;;更新图元一个端点
  (defun fs_ed_uppt (me oldpt verge / en ipts newpt)
    (cond
      ((vlax-curve-isClosed me))
      (t
       (setq verge (vlax-ename->vla-object verge))
       (cond
	 ((setq ipts (fsxm-interpt (vlax-ename->vla-object me) verge 3))
	  (setq	ipts  (vl-sort ipts
			       '(lambda	(p1 p2)
				  (< (distance p1 oldpt) (distance p2 oldpt))
				)
		      )
		newpt (car ipts)
	  )
	  (cond
	    ((equal oldpt newpt 1e-6))
	    (t
	     (setq oldpt (trans oldpt 0 1))
	     (setq newpt (trans newpt 0 1))
	     (command ".lengthen" "dy" (list me oldpt) "non" newpt "")
	    )
	  )
	 )
       )
      )
    )
  )
  ;;用关联数据更新一个图元＆关联图元
  (defun fs_up_enss (lst / en enep enptlst ensp en_e en_s)
    (setq en (car lst))
    (setq en_s (cadr lst))
    (setq en_e (caddr lst))
    (setq enptlst (last lst))
    ;;en的起点
    (setq ensp (vlax-curve-getStartPoint en))
    ;;en的终点
    (setq enep (vlax-curve-getendPoint en))
    ;;处理自己
    ;;起点
    (if	en_s
      (fs_ed_uppt en ensp en_s)
    )
    ;;终点
    (if	en_e
      (fs_ed_uppt en enep en_e)
    )
    ;;处理别人
    (foreach enpt enptlst
      (fs_ed_uppt (car enpt) (cadr enpt) en)
    )
  )
  ;;程序从这里开始了
  (or (setq ss (ssget)) (fsxm-silenceexit))
  (foreach en (fsxm-ss->enlist ss)
    (if	(vl-position
	  (fsxm-getendxf en 0)
	  '("LINE" "ARC" "CIRCLE" "ELLIPSE")
	)
      (setq lst (cons (fs_ed_getenss en) lst))
    )
  )
  (setvar "cmdecho" 0)
  (defun *error* (msg)
    (vla-EndUndoMark *doc*)
    (princ)
  )
  (vla-StartUndoMark *doc*)
  (command ".undo" "be")
  (setvar "cmdecho" 1)
  (command (strcat "." cmd) ss "")
  (while (/= 0 (getvar "cmdactive")) (command "\\"))
  (setvar "cmdecho" 0)
  (mapcar 'fs_up_enss lst)
  (*error* "")
)
;;几个常用命令
(defun c:fs_amove () (fs_aedit "move"))
(defun c:fs_arotate () (fs_aedit "rotate"))
(defun c:fs_ascale () (fs_aedit "scale"))