@steveB It depends on how fast you need to operate.
If you have time to find the stack you could just always start from the same height and search the whole way down until you found a part. This works well when you have a long machine cycle that gives the robot time to "find" the next part to work on.
I have written a couple that use the built-in force feedback to find the stack, it then records the current z-height of the stack to use as the start parameter on the next search loop. This worked well in a sheet metal operation. Once we reached a certain stack height it then notified the operator to add more parts, there was also a sensor under the stack to ensure that we knew there were parts there or not so that the robot didn't try to pick up the locating fixture the pieces were on. This system used vacuum to pick up the metal pieces that were being assembled.
Another option if you want to search but not use the force is to install a proximity sensor on the tool that can let you know when you are just a couple mm away from the part.
I want to try and destack, load a machine, unload the machine then stack metal tubes. The canned program in the UR is good but it doesn't work well when you always have different heights in the racks that you are picking and placing in. I created a search sequence and made my own destack and stack program but it is quite cumbersome with lots of variables. Has anyone had any success doing anything like this?