Application of ActiveX Technology in Tool CAD

Summary:Using ActiveX technology to manipulate AutoCAD objects directly in other applications, the close combination of calculation program and drawing program is realized, and the traditional mode of using data files to link calculation programs and drawing programs when using secondary languages ​​such as Autolisp and ADS is changed. .
Fig.1 The connection mode of calculating program and drawing program in traditional cutter CAD
Figure 2 Connection model using ActiveX technology 1 Introduction Traditional tool CAD applications are mostly developed with Autolisp or ADS under the AutoCAD R14 version. Since the tool design involves the calculation and verification of tool parameters and the drawing of the tool, when developing such CAD application software, in order to increase the speed of calculation, the contents of the two parts are usually designed separately. At the same time, the data files will be used. The calculation, verification program and drawing program are linked together, that is, the tool parameters after calculation and verification are first output to the data file. Then in the drawing program to access the data file, read out each line of data, and finally after the corresponding processing to generate graphical data and draw the tool graphic. The connection mode between the calculation program and the drawing program is shown in Figure 1. Although this joint mode can achieve tool design function. However, due to the decentralized structure and the complicated processing of the data files in the drawing program and the strict observance of the operation sequence, the operation speed is slow, the use is inconvenient, and the degree of automation is low. With Microsoft's integration of ActivcX technology into development tools in AutoCAD 2000 or later, AutoCAD ActiveX technology can now be used to directly integrate calculations, verification programs, and drawing programs without having to go through intermediate data files. The connection mode using ActiveX technology is shown in Figure 2. This method is not only fast, easy to use, but also highly automated. 2 Introduction to ActiveX Technology ActiveX is the name of the visual control structure based on the ComponentO Object Model (COM). It is a packaging technology that provides packaged COM components and places them into applications. The ActiveX control is a COM component that supports the required protocols used in the visual development tools. Many applications (such as Microsoft Excel, Microsoft Word, Microsoft Access, Visual Basic, Visual C++, Delphi, etc.) support ActiveX technology and can manipulate ActiveX objects from within the program. AutoCAD ActiveX is an application of ActiveX technology in AutoCAD. It not only provides a mechanism for controlling programming within AutoCAD, but also enables control programming outside AutoCAD by opening AutoCAD objects to the outside world. The AutoCAD ActiveX object model is shown in Figure 3.
[s]. Collection object [o]. Object Figure 3 AutoCAD ActiveX object model 3 The method of manipulating AutoCAD objects in VB The use of ActiveX controls provides objects similar to the operation of other objects, that is, first assign an object reference to the variable, Then write code that uses methods, properties, and events for the object. The AutoCAD object is open in AutoCAD ActiveX and can be directly manipulated in VB. The specific method is as follows: In the VB project, reference the AutoCAD type library: Select the References option in the Project menu, open the References dialog box, and then From the AutoCAD Release 15 (AutoCAD 2000 Object Library) type library, as shown in Figure 4. Set AutoCAD program objects and document objects in the program code. Objects are processed in AutoCAD drawing files through AutoCAD ActiveX objects, properties, and methods.
Figure 4 Reference the AutoCAD type library in the project
Figure 5 Typical Complex Tool CAD System Interface 4 Application Example Take the typical complex tool CAD system developed by the University of Quzhou as an example. The system uses VB as a development platform and uses ActiveX technology to successfully implement a close combination of a calculation program and a drawing program. References to AutoCAD Type Libraries in the Project As described in the previous section, here are only how to set up AutoCAD program objects and document objects, and how to manipulate AutoCAD entity objects. The tool CAD system interface is shown in Figure 5. After entering the known condition parameters and selecting the calculation option of the tool menu, the system can automatically calculate the result. If the calculation is verified to be acceptable, the tool drawing may be generated by selecting the drawing option of the tool menu. In this menu option, use the following code to achieve the connection with the AutoCAD application and generate the tool graphic entity: