I've attached a file showing what i'm trying to do. Here's some pseudo-code:
segmentWidth = 4.2
sectionLength = XSectionLength
newSegmentWidth = sectionLength / floor(sectionLength / segmentWidth)
scaleFactor = (newSegmentWidth / segmentWidth) * 100
But it's not doing this, and the one time it was working, it seemed to be working at low-precision (I was getting gaps and snapping).