Aimed at the problem of reading and controlling UG files by OpenGL in VC++ environment, a method of object-oriented programming is proposed. The OpenGL single document, multiple documents and visualization windows are created by using the classified idea in VC++ environment. PRT format data files of UG are converted to DXF format data files. Not only the conversion rate but also the conversion quality of different format data file are ensured by using the intermediate conversion format CGM and the problems of redundancy lines and view missing are prevented. DXF files are converted to 3DS files by 3DS MAX software. Controlling and redrawing of UG files in OpenGL are realized. The Object-oriented method is better than process-oriented program design method on the reliability and operability of procedure. The method has been applied in the virtual CNC milling system and provided a theoretical basis for the development of visualization system.