In the trajectory planning process of spray painting robot, an approach to automatic trajectory generation of spray gun using point cloud slicing is presented. Firstly, the point cloud data is obtained by scanning the surface of the workpiece. After the uniform slicing of point cloud model, the spraying position is determined by the average sampling of cross-section contours. Then the normal vectors of the sampling points are estimated. Finally the trajectory of spray gun is generated by offsetting the sampling points along their normal vectors. Experimental results show that the method has good feasibility and effectiveness. The spraying trajectory, direction and distance of spray gun can be controlled accurately, thus the spraying quality and efficiency are improved.