Assuming the hatch is associative, try this:
(defun c:foo (/ lw s v)
(if (setq s (ssget ":L" '((0 . "HATCH"))))
(foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
(and (setq lw (cdr (assoc 330 (reverse (entget e)))))
(setq v (cdr (assoc 38 (entget lw))))
(vla-put-elevation (vlax-ename->vla-object e) v)
)
)
)
(princ)
)