How to get in order the coordinates of all corners from any mesh?

I sent a link to a video showing approximately how it should work. My task is to replace complex objects with my own models in real time. In the video, I used splines, but I manually hardcoded the corner coordinates using sockets