Just to amuse myself, here is a snippet that will flatten simple entities, not sure if that helps you along the way - you can use what code works for 3d polylines, hatches, regions and blocks - might be a bit quicker
 
	 
 
	Command: NewFlatten
 
	 
 
	 
 
	An edit for later...
 
	 
 
(defun FlattenLines ( Pt1 Pt2 / MySS MyEnt acount ed)
;;For arcs, attdef, circle, (dimension N/A), Insert, Line, LWPolyline, Mtext, Point, text,  
;;Does lines, circles, arcs, ellipses, texts, LWPolylines
  (if (< (car pt1)(car pt2))
    (setq MySS (ssget "_W" pt1 pt2 (list
      '(-4 . "<OR")
        '(-4 . "*,*,<>") (list 10 0.0 0.0 0.0)
        '(-4 . "*,*,<>") (list 11 0.0 0.0 0.0)
        '(-4 . "<>") (cons 38 0)
      '(-4 . "OR>")
    ))) ; end list, ssget, setq
    (setq MySS (ssget "_C" pt1 pt2 (list
      '(-4 . "<OR")
        '(-4 . "*,*,<>") (list 10 0.0 0.0 0.0)
        '(-4 . "*,*,<>") (list 11 0.0 0.0 0.0)
        '(-4 . "<>") (cons 38 0)
      '(-4 . "OR>")
    ))) ; end list, ssget, setq
  ) ; end f
;  (setq MySS (ssget "_X" (list
;    '(-4 . "<OR")
;      '(-4 . "*,*,<>") (list 10 0.0 0.0 0.0)
;      '(-4 . "*,*,<>") (list 11 0.0 0.0 0.0)
;      '(-4 . "<>") (cons 38 0)
;    '(-4 . "OR>")
;  ))) ; end list, ssget, setq
  (setq acount 0)
  (while (< acount (sslength MySS))
    (setq MyEnt (ssname MySS acount))
    (setq ed (entget MyEnt))
    (if (equal (assoc 0 ed) (cons 0 "LWPOLYLINE"))
      (progn
        (entmod (setq ed (subst (cons 38 0) (assoc 38 ed) ed) )) ;; Elevation to 0
      ) ; end progn
      (progn
        (entmod (setq ed (subst (cons 10 (mapcar '* '(1 1 0) (cdr (assoc 10 ed)))) (assoc 10 ed) ed)) )
        (entmod (setq ed (subst (cons 11 (mapcar '* '(1 1 0) (cdr (assoc 11 ed)))) (assoc 11 ed) ed)) )
      ) ; end progn
    ) ; end if
    (setq acount (+ acount 1))
  ) ; end while
)
(defun SSMouseOrder (  / MyList MySS pt1 pt2 MyEnt SelSS MySS MyDuir acount)
;; Enttypelist: wildcards are OK but not for single selection.
;; Enttypelist in CAPITALS for single entity selection to work.
  (princ " (Crossing selection, not single picks please). ")
;;Set up LISP
  (setq MySS (ssadd))                          ;; Blank Selelection Set
  (if (= EntTypeList nil)(setq EntTypeList (list "LINE" "ARC" "CIRCLE")) ) ;; default entity filter
  (setq MyList (list (cons -4 "<OR") ))        ;; Create filter to use with ssget
  (foreach n EntTypeList
    (setq MyList (append MyList (list (cons 0 n)) ) )
  ) ; end foreach
  (setq MyList (append MyList (list (cons -4 "OR>")) ) )
  (while (setq pt1 (getpoint "Select Objects:"));; Loop to select entities
    (setq pta pt1) ; record pt1 selected
    (if (setq MyEnt (car (nentselp pt1)))       ;; If 1st point selected was on an entity: Single entity selected
      (progn
        (if (ssdel MyEnt MySS)                  ;; If entity is in selected selection set, delete it
          (progn
            (redraw MyEnt 4)                    ;; Take away highlight
          )
          (progn                                ;; Else add single entity to selection set
            (If (member (cdr (assoc 0 (entget MyEnt))) EntTypeList) ;;Check entity type is desired
              (progn
                (setq MySS (ssadd MyEnt MySS))  ;; Add to selection set
                (princ (strcat " 1 Found, "))   ;; Report selection found
                (redraw MyEnt 3)                ;; highlight entity
              ) ; end progn
            ) ; end if member
          ) ; end progn
        ) ; end if ssdel
      ) ; end progn
      (progn                                    ;; Else if clicked point not an entity
        (setq pt2 (getcorner pt1 " Specify Opposite Corner")) ;;get 2nd point
        (if (< (car pt1)(car pt2))              ;; Left to right, right to left to determine window or crossing filter
          (setq SelSS (ssget "_W" pt1 pt2 MyList) ) ;; Get selected entities
          (setq SelSS (ssget "_C" pt1 pt2 MyList) )
        )
        (setq acount 0)
        (if SelSS                               ;; If anything was selected
        (progn
          (princ (strcat " " (rtos (sslength SelSS) 2 0) " Found, ")) ;; report how many entities selected
          (while (< acount (sslength SelSS))   ;; add entities to selection set
            (setq MySS (ssadd (ssname SelSS acount) MySS))
            (redraw (ssname SelSS acount) 3)   ;; Highlight each entity
            (setq acount (+ acount 1))         ;; Loop counter
          ) ; end while
        ) ; end progn
        ) ; end if SelSS
      ) ; end progn
    ) ; end if MyEnt
    (setq MyDir 0)                             ;; Work out mouse click directions. Note single selection direction is LL->UR
    (if (< (cadr pt1)(cadr pt2))               ;; Horizontal
      (setq MyDir 0)
      (setq MyDir 1)
    )
    (if (< (car pt1)(car pt2))                 ;; Vertical
      (setq MyDir (+ MyDir 0))
      (setq MyDir (+ MyDir 2))
    )
  ) ; end while
  (setq acount 0)                             ;; clear highlights
  (while (< acount (sslength MySS))
    (redraw (ssname MySS acount) 4)
    (setq acount (+ acount 1))
  )
  (if (= (sslength MySS) 0)                   ;; report the selection set and direction or nil if no selection
    nil
    (list MySS MyDir)                         ;; MyDir: 0 BL->TR (or point selection), 1 TL->BR, 2 BR->TL, 3 TR->BL
  )
  (list pta pt2 MyDir) ; MyDir 0, 1-> L to R, 2, 3 -> R to L
)
(defun c:NewFlatten ( / Pts)
  (princ "Selection: ")
  (setq Pts (SSMouseOrder)) ;;Mouse order returns Selection set points. Used later.
  (FlattenLines (car Pts) (cadr Pts) ) ;; flatten simple entities
) ; end defun