Auto dimensions

 From:  Peticel
11637.12 
I'm not sure where the problem is coming from.
The model was created face up, as part of a larger array. If I run the script in that position, everything is fine.

When I move or rotate the object so that the 'face' faces the front view, one of the sizes breaks.

I have attached the file and the script.