In order to realize the rotation of permanent magnet synchronous motor and to carry magnetic flux density analysis of motor at 3-phase voltage load out, a set of ANSYS secondary development programming method with APDL is proposed in this paper. In this programming method, firstly, the rotational angle of the rotor at any time is calculated by two parameters of time and rotational speed. Secondly, the 3-phase voltage load at corresponding time can be got by two parameters of time and the 3-phase voltage frequency. Finally, according to the rotational angle of the rotor at any time and the 3-phase voltage load at the corresponding time, the whole process of the motor rotation is realized with ANSYS loop statement. This programming method solves the difficult problem that the rotor doesn’t rotate for ANSYS magnetic analysis and the magnetic flux density of permanent synchronous motor can be calculated more exactly.