(defun c:mhatch ()
(setq cmdecho (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(command "UNDO" "G")
(setq sset (ssget '((-4 . "<OR")(0 . "POLYLINE")(0 . "LWPOLYLINE")(-4 . "OR>"))))
(if sset
(progn
(setq num (sslength sset) itm 0)
(while (< itm num)
(setq hnd (ssname sset itm))
(command "_HATCH" "_S" hnd "")
(setq itm (1+ itm))
)
(command "_DRAWORDER" sset "" "_F")
)
)
(command "UNDO" "E")
(setvar "CMDECHO" cmdecho)
(princ)
(setq cmdecho (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(command "UNDO" "G")
(setq sset (ssget '((-4 . "<OR")(0 . "POLYLINE")(0 . "LWPOLYLINE")(-4 . "OR>"))))
(if sset
(progn
(setq num (sslength sset) itm 0)
(while (< itm num)
(setq hnd (ssname sset itm))
(command "_HATCH" "_S" hnd "")
(setq itm (1+ itm))
)
(command "_DRAWORDER" sset "" "_F")
)
)
(command "UNDO" "E")
(setvar "CMDECHO" cmdecho)
(princ)