After all said and done it distills down to one function:
(defun _GetPileCutoffElev ( pile / shapeinfo points result )
;; Caller's responsibility to ensure a valid AutoPlant
;; structural pile object is passed as well as ensuring
;; AutoPlant structural enabler arx/dbx files are loaded
;; prior to calling this function or splat: rake in face.
;; ---------------------------------------------------
;; Thanks to Kerry Brown for distilling assistance.
(setq shapeinfo
(vlax-create-object
"PSCOMWRAPPER.Ks_ComShapeInfo"
)
)
(vlax-invoke
shapeinfo
'SetObject
pile
)
(vlax-invoke
shapeinfo
'Getinfo
)
(setq result
(if
;; determine type of pile ...
(<
(apply 'distance
(mapcar
'(lambda (p) (list (car p) (cadr p)))
(setq points
(mapcar
'(lambda (x) (vlax-get shapeinfo x))
'(MidLineStart MidLineEnd)
)
)
)
)
0.001
)
;; it's a normal pile, get the highest z value
(apply 'max (mapcar 'last points))
;; it's a battered pile, get the normalized z value
;;
;; see image at:
;;
;; http://www.theswamp.org/screens/mp/batteredpile.png
;;
;; ASCII representation is idealized elevation, side ab
;; is the CL of the pile; p1 = point a, p2 = point b.
;;
;; elev
;; ------ + b (p2)
;; /|\
;; / | \
;; / | \ result
;; / e +---+ d --------
;; / |
;; (p1) a +-----+ c
;;
;; Angles in representation are not proportionate: Angle
;; a-b-d = 90, whereas angle e-b-d equals angle c-a-b.
;;
;; Side bd is the radius of the pile.
;;
;; Elevation at point 'e' is the desired result.
( (lambda ( p1 p2 radius)
(- (apply 'max (mapcar 'last (list p1 p2)))
(* radius
(/ (distance p1 (list (car p2) (cadr p2)))
(distance p1 p2)
)
)
)
)
(car points)
(cadr points)
(/ (vlax-get pile 'Width) 2.0)
)
)
)
(vlax-release-object shapeinfo)
result
)