I suspect that these guidepoints are only “out of position” along the red axis because you deal with scaled shelfs along the red axis only.
What happens if you select all the shelfs { one at a time > right click > select ‘Scale Definition’ (to make them the larger unscaled components } > and only then run the script.
Just a guess