Here ya go, John......at the end is the code for 1 of the blocks. You can make up the others by just changing the name of the function "c:surf40" to whatever names you want to use for the command and changing the block name to match....
Code:
(defun attsurf (bname / acadobj aecapp aecProj aecsurfs aecsurf aecutil e-n
emsg pt# selev appstr versn *error* att blk space)
(defun *error* (msg / objlist)
(setq objList
(reverse
(list acadobj aecapp aecProj aecsurfs aecsurf aecutil)
)
)
(vl-catch-all-apply
'(lambda ()
(mapcar 'vlax-release-object objlist)
)
)
(if msg
(princ (strcat "\n" msg))
)
(princ)
)
;;;;;
(setq appstr (cond ((= (setq versn (atoi (substr (getvar "acadver") 1 2))) 15) "2")
((= versn 16) "4")
((= versn 17) "6")
)
)
(setq acadObj (vlax-get-acad-object)
space (vla-get-modelspace (vla-get-activedocument acadObj))
aecApp (vla-getinterfaceobject acadObj (strcat "Aecc.Application." appstr))
aecProj (vlax-get aecApp "Activeproject")
aecSurfs (vlax-get aecProj "Surfaces")
aecSurf (vlax-get aecSurfs "Currentsurface")
aecUtil (vlax-get (vlax-get aecApp "activedocument") "Utility")
)
(if (and (= aecSurf "")
(> (vlax-get aecSurfs "count") 0)
)
(setq aecSurf (vlax-get (vlax-invoke aecSurfs "item" 0) "name"))
)
(if (= aecSurf "")
(princ
"\nNo surfaces defined, try again after creating a surface."
)
(progn
(setq aecSurf (vlax-invoke aecSurfs "item" aecSurf))
(while (setq
pt# (getpoint "\nPoint to label on the current surface: ")
)
(setq e-n (vlax-invoke aecutil "xytoeastnorth" pt#))
(setq selev (vlax-invoke
aecSurf
"getelevation"
(car e-n)
(cadr e-n)
)
)
;;Insert your block insertion and attribute setting here
(setq blk (vlax-invoke space 'insertblock pt# bname 1.0 1.0 1.0 0.0))
(setq att (car (vlax-invoke blk 'getattributes)))
(vla-put-textstring att (rtos selev 2 2))
;(princ (strcat "\nElevation at point = " (rtos selev)))
)
)
)
(*error* nil)
)
;;;make as many of these as you need, this is for the SPOTL40 block
(defun c:surf40 ()
(attsurf "spotl40")
(princ)
)
Note that there is a bug in the LDD API when using surfaces in lisp that sometimes raises an error. If you encounter this, just re-open the drawing. This will clear the lisp cache.....although in rare cases a full exit from Acad is required. I have not seen it cause any data or dwg corruption, it is more of a nuisance.....and I did not see it at all in the testing I did with this routine.
Enjoy!
Jeff