In a numerically controlled machining device a method of retracting from and returning a tool respectively to a workpiece during the execution of a program for machining a surface of said workpiece, wherein during said machining the tool being controlled is to follow a tool machining path determined from a calculated tool path and wherein for each reference position on the calculated tool path there is an associated machining position on the tool machining path, said method comprising the steps of:
- (a) interrupting the tool progression on the tool machining path along the workpiece during said machining;
- (b) storing a first set of data which identify the progress reached in the interrupted machining program and a second set of data which identify the reference position reached at the beginning of the interruption;
- (c) determining a tool retraction position which is situated remote from the workpiece;
- (d) moving the tool to said tool retraction position;
- (e) fetching said second set of data, and determining, on the basis of said reference position reached at the beginning of the interruption, a restart reference position which has its associated restart machining position situated on the tool machining path on a location already reached by the tool before said interruption occurred;
- (f) determining a calculated return path which extends between the retraction position and a restart reference position, and wherein at least a part of said calculated return path describes a curved portion which, near the restart reference position, diverges towards a line interconnecting successive reference positions of the calculated tool path, and wherein said calculated return path extends substantially in the same direction as the calculated tool path near the restart reference position;
- (g) determining a tool return path on the basis of said calculated return path;
- (h) under control of a generated restart command;
- (h1) fetching said first set of data;
- (h2) returning the tool to the workpiece along said tool return path;
- (h3) restarting the interrupted machining program by using the first set of data when said tool has reached the restart machining position.