Assuming that MEP Objects use an Elevation Property to store the data you modify in Properties Palette, and not a dynamically calculated value like Pipe Center, for Invert, etc. as is the case in Civil 3D:
Code:
(vl-load-com)
(defun c:FOO (/ *error* e sourceObject ss targetObject acDoc)
(defun *error* (msg)
(if acDoc
(vla-endundomark acDoc)
)
(cond ((not msg)) ; Normal exit
((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit)
((princ (strcat "\n** Error: " msg " ** "))) ; Fatal error, display it
)
(princ)
)
(if
(and
(setq e (car (entsel)))
(setq sourceObject (vlax-ename->vla-object e))
(vlax-property-available-p sourceObject 'elevation)
(setq ss (ssget ":S:E:L"))
(setq targetObject (vlax-ename->vla-object (ssname ss 0)))
(vlax-property-available-p targetObject 'elevation)
)
(progn
(vla-startundomark
(setq acDoc (vla-get-activedocument (vlax-get-acad-object)))
)
(vla-put-elevation targetObject (vla-get-elevation sourceObject))
)
(cond
(targetObject
(prompt
"\n** Target object does not have an \"Elevation\" Property ** "
)
)
((and sourceObject (not ss))
(prompt
"\n** Source object does not have an \"Elevation\" Property ** "
)
)
)
)
(*error* nil)
)