(princ "\n*****边界轮廓线：fs_outline 飞诗寻梦作品*****")
(defun c:fs_outline (/ a b box h h/2 lst pt pt1 pt2 ss *error*)
  (setq *error* strcat)
  (setq ss (ssget))
  (setq box (fsxm-ss-box ss))
  (setq h (fsxm-pickboxsize))
  (setq h/2 (/ h 2))
  (setq pt1 (mapcar '+ (cadr box) (list h h)))
  (setq pt2 (mapcar '- (car box) (list h h)))
  (setq pt (mapcar '+ (cadr box) (list h/2 h/2)))
  (setq pt (trans pt 0 1))
  ;;start
  (setvar "cmdecho" 0)
  (defun *error* (msg)
    (command ".undo" "e" ".undo" "1")
    (princ msg)
    (princ)
  )
  (command ".undo" "be")
  ;;画边框
  (entmake
    (list '(0 . "LWPOLYLINE")
	  '(100 . "AcDbEntity")
	  '(100 . "AcDbPolyline")
	  '(90 . 4)
	  '(70 . 1)
	  '(60 . 1)
	  (cons 10 pt1)
	  (list 10 (car pt2) (cadr pt1))
	  (cons 10 pt2)
	  (list 10 (car pt1) (cadr pt2))
    )
  )
  (ssadd (setq box (entlast)) ss)
  ;;边界轮廓
  (command ".boundary" "a" "b" "n" ss "" "i" "y" "o" "r" "" "non" pt "")
  (while (/= 0 (getvar "cmdactive")) (command ""))
  (setq lst (fsxm-newenlist box))
  (setq ss (ssadd))
  (foreach en lst (ssadd en ss))
  (setq	lst (mapcar '(lambda (a)
		       (list (vla-get-Area (vlax-ename->vla-object a)) a)
		     )
		    lst
	    )
	lst (vl-sort lst '(lambda (a b) (> (car a) (car b))))
  )
  ;;删除边框面域
  (entdel (cadar lst))
  (if (> (sslength ss) 2)
    (command ".union" ss "")
  )
  (command ".explode" ss "")
  (setq ss (fsxm-newselection box))
  (sssetfirst nil ss)
  (if (setq ss (ssget ":S" '((0 . "line,arc,circle"))))
    (command ".pedit" "m" ss "" "y" "j" 1e-6 "")
  )
  (setq ss (fsxm-newselection box))
  (command ".change" ss "" "p" "c" 1 "")
  ;;删除边框
  (entdel box)
  (command ".undo" "e")
  (sssetfirst nil ss)
  (princ "\n-\n--\n--->>>程序运行完成.......请查收！")
  (princ)
)