A parameterized three-dimensional (3D) finite element model (FEM) of T2120 deep hole drilling and boring machine tool body was established by using APDL language of ANSYS software that exampled to structure optimization of machine tool body. The modal analysis of the body structure was done by using Block Lanczos module of ANSYS, the first five stages of natural frequencies and the first three stages of low-frequency vibration mode were obtained. The optimization of structural parameters of the machine tool body in the condition of fundamental frequency constraint was further enhanced by using Block Design Opt module of ANSYS, and the ideal structure size of machine tool body was gotten. The result shows that the weight of machine tool body after optimization is decreased by 7.23%. Meanwhile it also shows that the use of APDL provides important guidance value to speed up the progress of the analysis and improve the efficiency of the design.