distance between origin and face

Smconvert will choose the reference face for a single flange part randomly (or based upon the first big face in the solid). Depending on how it was created you can get the upper or lower face as reference. I would like to make the face with lowest z value/elevation the reference side.
Therefor I'm creating some code that will check if a single flange is present in the drawing, then check the top flange face elevation and bottom. if the bottom elevation has a higher z value then I would call the smflip command.
Issue for now is that I can't seem to find how to retrieve the distance between faces in lisp. I see 2 options here:

  • check whether distance from bottom to top is a positive value (or vice versa and expect negative value)
  • check distance from origin (0,0,0) to faces and compare these

face selection can be done with (smlispget "selectentities" "top" "Flange_1") or (smlispget "selectentities" "bottom" "Flange_1")

any advice here?

Karel