Not the prettiest code but try it nonetheless. Does everything (I think) you asked in one pass. What you may notice is that even tho it will explode plines for the dxf export, the original plines remain in the host drawing - any objects spawned from explode call are considered temporary, and removed after the command completes.
(defun c:Whargarbl ( / ss sst fn doc layer layers i e x spawn temp fly-ball cmdecho )
(vl-load-com)
(cond
( (null (setq ss (ssget '((0 . "arc,circle,line,lwpolyline,polyline")))))
(princ "\nNothing selected, command cancelled.")
)
( (null (setq fn (getfiled "DXF File:" (getvar 'dwgprefix) "dxf" 1)))
(princ "\nOutput file not specified, command cancelled.")
)
( (progn
(vl-catch-all-apply 'vl-file-delete (list fn))
(findfile fn)
)
(princ (strcat "\nOutput file <" fn "> is read-only, command cancelled."))
)
( (setq
doc (vla-get-activedocument (vlax-get-acad-object))
layer "Cut"
layers (vla-get-layers doc)
sst (ssadd)
)
(vla-add layers layer)
(vlax-for x layers (vla-put-lock x :vlax-false))
(repeat (setq i (sslength ss))
(cond
( (and
(setq x (vlax-ename->vla-object (setq e (ssname ss (setq i (1- i))))))
(vlax-method-applicable-p x 'explode)
(progn
(setq spawn (vl-catch-all-apply 'vlax-invoke (list x 'explode)))
(< 0 (length spawn))
)
)
(foreach o spawn
(vla-put-layer o layer)
(ssadd (vlax-vla-object->ename o) sst)
)
(setq temp (append spawn temp))
)
( t
(vla-put-layer x layer)
(ssadd e sst)
)
)
)
(setq cmdecho (getvar 'cmdecho))
(setvar 'cmdecho 0)
(if (vl-catch-all-error-p (setq fly-ball (vl-catch-all-apply 'vl-cmdf (list "_.dxfout" fn "_Objects" sst "" "_Version" "2000" ""))))
(princ (strcat "\nError: " (vl-catch-all-error-message fly-ball) "."))
)
(mapcar 'vla-delete temp)
(setvar 'cmdecho cmdecho)
)
)
(princ)
)
Cheers.