In this paper, a method of automatic NC code programming is studied. The data structure used to store graph information is the base of automatic programming system. By utilizing the object-oriented tree data structure proposed in the paper, the disadvantages of the method caused by using simple data structures can be overcome. In processing information, the judgment of topological relationship between two outlines is very important. The Loop Extremum Method is easy, convenient and with no limitations. The system adds plenty of technological parameters, provides multiple machining patterns. In the end, an example is given to test and verify the system`s functions.