One problem is to create a pulse when the laser sensor detects the work piece as it will not change back to 0 before the piece is past. I know only how to do that in classicladder.
That leads to the next challenge of signal speed because the work piece is moving and the signal of the laser sensor will require some time to be fed through the electronics and software. So by the time the DRO is set to "0" the work piece is going to be already past the sensor by some distance. There is no avoiding this but with a real time system you might be able to figure out how much offset the system has depending on the speed of the work piece.
Measuring the length of the piece might actually be the easier task because it involves also the negative edge and the delay in the second edge would compensate for the delay in the first.