Chapter 25. Visual LISP as ActiveX Client.
Visual LISP can act as an ActiveX client and server. This chapter demonstrates an alternative to the sample program in Chapter 24. If in that chapter we showed how to create a Table with drawing data, in that case the Block INSERT attributes. we will devote this Chapter to the way of exporting those data to an Excel spreadsheet. As we already studied in Chapter 22 how to design a DCL dialog box, we will use this exercise to demonstrate the use of another tile, the list_box. The user interface of AutoCAD since release 2008 provides commands especially designed to establish these links without programming. The _DATAEXTRACTION command can be used for extracting drawing information to an Excel spreadsheet, an Access database table or to CSV and TXT exchange files. This command displays a dialog box to select the information and set its destination. It is our goal to explain in this Chapter the basic principles for doing this as a part of a Visual LISP application.
There are two ways to access the methods and properties of an application that can act as an ActiveX server. We can import its type library using vlax-import-type-library, or we can use the generic functions vlax-invoke-method, vlax-get-property and vlax-put-property to access to its methods and properties in a very simple and straightforward way. This second procedure is enough for programs that don’t require full control of the other application. This way we are able to achieve our goals without loading in memory all the objects in the server application. It’s the one we’ll use in the program proposed here.
Spreadsheet with the exported attribute data. |
We believe that, once explained, it may surprise how simple it is to set up a connection between Visual LISP and an application like Excel in order to export drawing data directly to the spreadsheet. In fact, most of the code in this application has nothing to do with this. It deals with data extraction and GUI management. I’ve waited to have an application like this, of a certain complexity to address a pending topic: compilation. To it we will devote the next chapter.
This Chapter includes the following sections:
25.1. Tutorial: From AutoCAD to Excel.
25.2. Writing in the Worksheet.
25.3. The Dialog box.
25.4. Project Structure.
25.5. Summary.
Chapter 25 Source code.
Your questions or comments about this Chapter's contents are welcome!
Chapter 26. VLX: The Visual LISP Executable.
In the previous Chapter we completed the code for a program that exports attribute values of the selected block to an EXCEL spreadsheet. This program includes three LISP source files and one with the DCL code for a dialog box. Managing a project of some complexity like this one can profit from the tools provided by the Visual LISP Integrated Development Environment (IDE).
The source code files can be structured as a project. This allows us to open any file by double-clicking in the project window. It also enables searching for expressions in all of the project files, and loading all the source code files at the same time. But the greatest advantage in applications like this one is the possibility packing it for its distribution as a single compiled file, including the dialog interface.
The source code files can be structured as a project. This allows us to open any file by double-clicking in the project window. It also enables searching for expressions in all of the project files, and loading all the source code files at the same time. But the greatest advantage in applications like this one is the possibility packing it for its distribution as a single compiled file, including the dialog interface.
Usually a real application will be even more complex than the one we have developed. It can include thousands of code lines distributed among a large number of LSP files. This source code can be compiled to increase efficiency, a process in which other intermediate and executable files are generated. Keeping track of all these files can become very cumbersome, for example to determine when modified files should be recompiled or the whole application rebuilt. The parameters that specify how to compile and build the application according to its characteristics may also be set. If other resource files (dialog definitions or text files) are to be included, it is advisable to package them as a single VLX file.
This chapter forms a unit with the previous one, showing the steps to build a compiled application, from our source code. This application although simple, meets all the requirements expected of a professional job. At this point the reader will have accumulated sufficient knowledge to venture into the development of their own ideas.This Chapter includes the following sections:
26.1. Managing an Application.
26.2. The VLISP Project Manager.
26.3. Namespaces.
26.4. Creating the Application Module.
26.5. Summary.
Your questions or comments about this Chapter's contents are welcome!
No comments:
Post a Comment