Make BuildLineArray dynamic

Close #2926