(defun _surfaceElevationAtPoint (point / i n x s e p f)
(if (and (vl-consp point)
(setq i -1
n (trans (getvar 'VSMIN) 0 1)
x (trans (getvar 'VSMAX) 0 1)
s (ssget "_C" (list (car n) (cadr n)) (list (car x) (cadr x)) '((0 . "AECC_*SURFACE")))
)
)
(while (and (not f) (setq e (ssname s (setq i (1+ i)))))
(if (not (vl-catch-all-error-p
(setq p (vl-catch-all-apply
'vlax-invoke
(list (vlax-ename->vla-object e)
'FindElevationAtXY
(car point)
(cadr point)
)
)
)
)
)
(setq f p)
)
)
)
f
)
- what happens if I have two surfaces above each otherIsn't the (vlax-ename->vla-object e) already "selecting"the entity in ActiveX? The e being the ename of the surface object.
I have no example to can test it, but
(vlax-get-property (vlax-ename->vla-object e) 'DisplayName)
gives me the surface there I generate a surfacepoint
Is it opportunity to select a surface with ActiveX?
ObjectReference.MethodName(Arg1, Arg2, ... ArgN) 'For calling a method
variable = ObjectReference.MethodName(Arg1, Arg2, ... ArgN) 'For calling a method and setting its result into a variable
variable = ObjectReference.PropertyName 'For setting the value of a property into a variable
ObjectReference.PropertyName = variable 'For setting the value in a variable into the property
The same code can be written in these 3 ways in VLisp(setq elev (vlax-invoke surf 'findelevationatxy (car pt) (cadr pt)))
Jeff and Alan gaves me example to can get properties of getting point on a surface. How did they know which properties haves vla-oject AcadSurface. If I look in explanation to AcadSurface (vla-object AcadSurface) I find this (image). How can I get information to the line especially what is "function" 'findelevationatxy and what did it need. I don´t get it, but I would like know where I can read, what it meansYou found the Help for an AcadSurface which is not the same as the AeccTinSurface or AeccSurface. You can find the help files for the Civil COM (ActiveX) libraries HERE (http://wikihelp.autodesk.com/AutoCAD_Civil_3D/enu/2014/Help/COM_Reference_Guide)
(defun c:SEI (/ ss i o surfaces pt elev lst)
;; Surface Elevation Inquiry
;; Extract elevation from point in Civil 3D surface(s)
;; Alan J. Thompson, 05.25.10 / 2013.07.03 (rewrite)
(if (setq ss (ssget "_A" '((0 . "AECC_*SURFACE"))))
(repeat (setq i (sslength ss))
(setq o (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
(if (not (eq (vla-get-stylename o) "_No Display"))
(setq surfaces (cons (cons (vla-get-name o) o) surfaces))
)
)
)
(if (null surfaces)
(alert "No visible surface in drawing.")
(while (setq lst nil
pt (getpoint "\nSpecify point on surface: ")
)
(setq pt (trans pt 1 0))
(foreach surface (vl-sort surfaces (function (lambda (a b) (> (car a) (car b)))))
(if (not (vl-catch-all-error-p
(setq elev (vl-catch-all-apply
'vlax-invoke
(list (cdr surface) 'FindElevationAtXY (car pt) (cadr pt))
)
)
)
)
(setq lst (cons " "
(cons "(\""
(cons (car surface)
(cons "\" ~ " (cons (rtos elev) (cons ")" lst)))
)
)
)
)
)
)
(if lst
(princ (apply 'strcat (cons "\n" (cdr lst))))
(princ "\nPoint outside of surface.")
)
)
)
(princ)
)
(vl-load-com)
(princ)
Hi Alan!Feel free to ask any questions. I basically make a selection set in the beginning of the routine, which will also prompt the user if there are nor valid/visible surfaces in the drawing.
Thank you for your fantastic work you´ve done. I´m so happy it works perfect. I must testing little more, how it works - doesn´t have much experience with surface-vla-objects.
how to select surface by layerIf you are trying to only select surfaces on a specified layer, you can add a layer filter to the ssget function (cons 8 "LayerName").