UNITS block set the scaling "factor", but was positioned below the XY block. So the XY block was using the default factor value of 1. Default GDS values lead to factor=0.001, and with this not being accounted for in each XY element, GDSs in microns were suddenly scaled up to mm.
I don't see how the block being moved inside the series of if/else clauses will have any impact. What matters is the order in which the data is stored in the GDSII file being loaded.
UNITS block set the scaling "factor", but was positioned below the XY block. So the XY block was using the default factor value of 1. Default GDS values lead to factor=0.001, and with this not being accounted for in each XY element, GDSs in microns were suddenly scaled up to mm.