I think I misunderstood your explanation of what you needed.
Anyway, the code can be easily adapted to what you asked for.
I've corrected the small oversight in the 'grvecs' functions, which I included at the last minute and didn't check.
Here is the modified code, in case anyone finds it useful...
(defun c:ptoZmin? (/ ent lstent punto lstpts zMin ptoZmin conj n)
(setq n 0)
(if (setq conj...