Lengths of lines in a Triangular Grid on an A4 page

Side Length

d = 1 (slider from 0 to 5, step 0.01)
n = 12 (slider from 0 to 40, step 1)
m = 5 (slider from 0 to 40, step 1)
pSumBlue = Sequence(Sum[Sequence[Segment[(d * (1 - (-1)^(j)) / 4 + d * i, j * sqrt(3) * d / 2), (d * (1 - (-1)^(j)) / 4 + d * (i + 1), j * sqrt(3) * d / 2)], i, 0, m - 1]], j, 0, n)
SumBlue = Sum(pSumBlue)
pSumRed = Sequence(Sum[Sequence[Segment[(d * (1 - (-1)^(j)) / 4 + d * (i + (1 + (-1)^(j)) / 2), j * sqrt(3) * d / 2), (d * (1 - (-1)^(j + 1)) / 4 + d * (i + (1 - (-1)^(j)) / 2), (j + 1) * sqrt(3) * d / 2)], i, 0, m - 1]], j, 0, n - 1)
SumRed = Sum(pSumRed)
pSumGreen = Sequence(Sum[Sequence[Segment[(d * (1 - (-1)^(j)) / 4 + d * i, j * sqrt(3) * d / 2), (d * (1 - (-1)^(j + 1)) / 4 + d * i, (j + 1) * d * sqrt(3) / 2)], i, 0, m]], j, 0, n - 1)
SumGreen = Sum(pSumGreen)
TotalLineLength: SumBlue + SumGreen + SumRed
inputBox1 = Textfield(d)
tmplist1 = Sequence(Sequence[(d * (1 - (-1)^(j)) / 4 + d * i, j * sqrt(3) * d / 2), i, 0, m], j, 0, n)
tmplist2 = Sequence(Sequence[Segment[(d * (1 - (-1)^(j)) / 4 + d * i, j * sqrt(3) * d / 2), (d * (1 - (-1)^(j)) / 4 + d * (i + 1), j * sqrt(3) * d / 2)], i, 0, m - 1], j, 0, n)
tmplist3 = Sequence(Sequence[Segment[(d * (1 - (-1)^(j)) / 4 + d * i, j * sqrt(3) * d / 2), (d * (1 - (-1)^(j + 1)) / 4 + d * i, (j + 1) * d * sqrt(3) / 2)], i, 0, m], j, 0, n - 1)
tmplist4 = Sequence(Sequence[Segment[(d * (1 - (-1)^(j)) / 4 + d * (i + (1 + (-1)^(j)) / 2), j * sqrt(3) * d / 2), (d * (1 - (-1)^(j + 1)) / 4 + d * (i + (1 - (-1)^(j)) / 2), (j + 1) * sqrt(3) * d / 2)], i, 0, m - 1], j, 0, n - 1)
list1 = Sequence(Sequence[(d * (1 - (-1)^(j)) / 4 + d * i, j * sqrt(3) * d / 2), i, 0, m], j, 0, n)
list2 = Sequence(Sequence[Segment[(d * (1 - (-1)^(j)) / 4 + d * i, j * sqrt(3) * d / 2), (d * (1 - (-1)^(j)) / 4 + d * (i + 1), j * sqrt(3) * d / 2)], i, 0, m - 1], j, 0, n)
list3 = Sequence(Sequence[Segment[(d * (1 - (-1)^(j)) / 4 + d * i, j * sqrt(3) * d / 2), (d * (1 - (-1)^(j + 1)) / 4 + d * i, (j + 1) * d * sqrt(3) / 2)], i, 0, m], j, 0, n - 1)
list4 = Sequence(Sequence[Segment[(d * (1 - (-1)^(j)) / 4 + d * (i + (1 + (-1)^(j)) / 2), j * sqrt(3) * d / 2), (d * (1 - (-1)^(j + 1)) / 4 + d * (i + (1 - (-1)^(j)) / 2), (j + 1) * sqrt(3) * d / 2)], i, 0, m - 1], j, 0, n - 1)
A = Intersect(a, e)
B = Intersect(b, e)
C = Intersect(b, c)
D = Intersect(a, c)
poly1, a_1, b_1, c_1, d_1 = Polygon(A, B, C, D)
text1: "Length of lines = " + TotalLineLength + ""