AutoCAD Object Model. |
ActiveX is a communications protocol that allows sharing software components between programs. These components, known as objects are containers that bring together both properties (i.e., data) and methods (procedures or functions). Visual LISP is able to use this ActiveX interface to incorporate new features similar to those that may be available to programmers in languages like Visual Basic or C++. ActiveX methods are represented by Visual LISP functions. These features are not available initially in the application. To use them the vl-load-com function should be called, which loads the Visual LISP ActiveX extensions.
Arrays and Variants are incorporated to Visual LISP through ActiveX. In addition, ActiveX Extensions expose the AutoCAD object model as a new Visual LISP data type, the VLA‑object (meaning Visual LISP-ActiveX).
When a Visual LISP uses ActiveX functions it actually establishes a communication between two different programming environments. Some data types are not shared by both environments. For example, the list is not accepted as data by ActiveX methods. Some data that LISP manages as lists should be converted into a Variant of array type to be recognized by the ActiveX interface. An array is something like a list, but its size is fixed and cannot contain more than one data type. A Variant is a general-purpose container able to hold the different ActiveX supported data types.
AutoCAD Application Properties and Methods. |
Object-oriented programming exposes methods and properties with which we can attain results that by other means may require a significant programming effort. To use these methods and access these properties we must use the data types reviewed above: safearrays, Variants and VLA-objects. Safearrays can also provide a highly effective way to manage large volumes of data. Variant data types are universal containers for the exchange of information between VLISP and ActiveX servers.
Although when we discuss operations on the drawing`s database we will expand on these issues, we advance in this Chapter the basic concepts regarding:
- Creating and using arrays.
- Data conversion to and from Variants.
- Access to VLA-objects and use of their properties and methods.
- How objects are organized into collections and the way we can operate on them.
- Programming methods using exceptions.
Recent additions to classical AutoLISP seem to point to a future in which this programming paradigm may be fully implemented without the need for ActiveX's COM interface.
This Chapter includes the following sections:
6.1. Safearrays.
6.2. Variants.
6.3. VLA-Objects.
6.4. Collections.
6.5. Working with methods and properties.
6.6. Collections processing.
6.7. Managing exceptions.
6.8. Summary
Chapter 6 source code.
Your questions or comments about this Chapter's contents are welcome!
Buy this book from Amazon.
Senor Togores,
ReplyDeleteThank you for sharing your knowledge and ideas. I purchased AEVL ca. 2012 and have used it extensively. I’ve used the text book so much the binding has broken!
sincerely- Juan P. Jimenez
hemeness@gmail.com