What this code does:
- Lines are no problem. Everywhere the Z value is set to 0
- Arc: Arcs have a center; I set its z-value to 0
- Polyline: they have an elevation, just a number. I set it to 0.
Things like polylines, circles, arcs... are always drawn on a UCS plane. If that plane is not parallel to the current plane, then this code will not do what you want.
I don't touch anything else, like blocks, 3D polyline, ... Just what you asked.
Command FLAT (feel free to rename)
(defun c:flat ( / ss i ent ip1 ip2 elv)
;; lines
(setq ss (ssget "_X" (list (cons 0 "LINE"))))
(setq i 0)
(repeat (sslength ss)
(setq ent (ssname ss i))
;; insert point start
(setq ip1 (cdr (assoc 10 (entget ent))))
;; add a z-value 0.0 , or replace the z-value by 0.0
(setq ip1 (list
(nth 0 ip1) (nth 1 ip1) 0.0
))
;; insert point start
(setq ip2 (cdr (assoc 11 (entget ent))))
;; add a z-value 0.0 , or replace the z-value by 0.0
(setq ip2 (list
(nth 0 ip2) (nth 1 ip2) 0.0
))
;; entity modify, by substituting groups
(entmod (subst (cons 10 ip1) (assoc 10 (entget ent)) (entget ent) )) ;; substitute IP start
(entmod (subst (cons 11 ip2) (assoc 11 (entget ent)) (entget ent) )) ;; substitute IP end
(setq i (+ i 1))
)
;; ARC
(setq ss (ssget "_X" (list (cons 0 "ARC"))))
(setq i 0)
(repeat (sslength ss)
(setq ent (ssname ss i))
;; insert point center
(setq ip1 (cdr (assoc 10 (entget ent))))
;; add a z-value 0.0 , or replace the z-value by 0.0
(setq ip1 (list
(nth 0 ip1) (nth 1 ip1) 0.0
))
(entmod (subst (cons 10 ip1) (assoc 10 (entget ent)) (entget ent) )) ;; substitute IP center
(setq i (+ i 1))
)
;; POLYLINE
(setq ss (ssget "_X" (list (cons 0 "LWPOLYLINE"))))
(setq i 0)
(repeat (sslength ss)
(setq ent (ssname ss i))
;; Elevation
(setq elv 0.0)
(entmod (subst (cons 38 elv) (assoc 38 (entget ent)) (entget ent) )) ;; substitute elevation
(setq i (+ i 1))
)
)