The On-machine measurement is usually based on the data of points. When data come from the CNC machine tools, the information they carry may be invalid. Therefore, it is unsuitable to compensate the errors by rotating and translating all data. In this paper, a practical algorithm is proposed to compensate the errors. Firstly, the valid data are picked out and sorted according to their normal vectors. By using the least square method, an error reference frame is constructed. Then the relation between the compensation values and coordinates of the theoretical points is derived. Finally, an example of aircraft structural parts is presented to validate the design.