There was a thread a few days ago about speeding up a LISP to do the same, have  look at that for ideas. I think the thread got as far as arcs are tricky to do with LISPs.
 
	 
 
	You could use the flatten command for small drawings.
 
	 
 
	 
 
	This snippet will filter a selection set to lines or LWPolylines to anything not 0 Z
 
	 
 
(setq MySS (ssget (list
    (cons 0 "*TEXT,INSERT,LINE,LWPOLYLINE")
    '(-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, end ssget
)
	 
 
	 
 
	Can be added to the other solutions herein the case that your drawing has a lot of lines / polylines / blocks it speeds it up a bit
 
	 
 
	Link to other thread: