The undulator line of the Shanghai soft X-ray Free-electron Laser facility (SXFEL) has very tight tolerances on the straightness of the electron beam trajectory.However, the beam trajectory cannot meet the lasing requirements due to the influence of beam position, launch angle and quadrupole offsets. Traditional mechanical alignment can only control the rms of offsets to about 100 µm, which is far from reaching the requirement. Further orbit correction can be achieved by beam-based alignment (BBA) method based on electron energy variations. K modulation is used to determine whether the beam passes through the quadrupole magnetic center, and the Dispersion-Free Steering (DFS) method is used to calculate the offsets of quadrupole and BPM. In this paper, a detailed result of simulation is presented which demonstrates that the beam trajectory with rms and standard deviation (σ) less than 10 µm can be obtained.