What is the easiest way to modify the current program for a column in which there are not 4 parts of the same height?
Does this mean that there are less than 4 parts in the column, or that the 4 parts in the column are different heights? Or possibly both?
If the only variable is that there may be fewer than 4 parts in the column, and the number of parts in the column is known, then you can store the number of parts in the current column in a register and divide your laser sensor reading by that register value to get part height.
If there are products coming in stacked like you have described, but the parts are of a different height, then the solution would be more complicated. Please post some of your code, as well as more details of the parts coming into your system.