(defun c:mini_MinEncrectang ( / old_cmd ss x)
  (mai_start nil)
  (mai_last_com "mini_MinEncrectang")
  (setq ss (mai_select_first '((0 . "spline,ellipse,circle,arc,*polyline,line,point")) "选择要生成最小面积外接矩形的线:<退出>" "没有选到线."))
  (initget "Y") 
  (setq ss
       (if (= "Y" (getkword "是否为每一个实体生成一个独立最小面积外接矩形[是(Y)]:<回车全部实体生成一个最小面积外接矩形>"))
           (mai_ssget_2_list ss)
           (list ss)
       )
  )
  (foreach x ss
    (setq x (apply 'append (mapcar 'cdr (mai_ssget_points x (list 2.5 (mai_chgunits 100)) (list nil nil nil))))
          x (mai_points_minrectang x)
    )
    (and x (mai_entmake "lwpolyline" (cons (last x) x)))
  )
  (mai_end)
)
