ActiveX and VBA Developer's Guide

ActiveX Automation interface:automation projects. AutoCAD Color Index numbers. Color property: TrueColor property:VB:automation projects. VBA:automation projects. Visual Basic for Applications. Visual Basic. automation projects:migrating to AutoCAD 2004:projects:automation. standard color names.

Introduction

This introduction describes the concept of exposing AutoCAD objects through an ActiveX Automation interface and programming those objects using the Visual Basic for Applications programming environment.

Topics in this section

Overview of AutoCAD ActiveX Technology Overview of AutoCAD Visual Basic for Applications (VBA) Interface AutoCAD ActiveX and VBA Together How This Guide Is Organized For More Information Sample Code Migrate Automation Projects

Please send us your comment about this page

Introduction >

Overview of AutoCAD ActiveX Technology

AutoCAD? ActiveX? enables you to manipulate AutoCAD programmatically from within or outside AutoCAD. It does this by exposing AutoCAD objects to the "outside world." Once these objects are exposed, they can be accessed by many different programming languages and environments and by other applications such as Microsoft? Word VBA or Excel VBA. There are two advantages to implementing an ActiveX interface for AutoCAD:

Programmatic access to AutoCAD drawings is opened up to many more programming environments. Before ActiveX Automation, developers were limited to an AutoLISP? or C++ interface. Sharing data with other Windows? applications, such as Microsoft Excel and Word, is made dramatically easier. An object is the main building block of any ActiveX application. Each exposed object represents a precise part of AutoCAD. There are many different types of objects in the AutoCAD ActiveX interface. For example: Graphical objects such as lines, arcs, text, and dimensions are objects. Style settings such as linetypes and dimension styles are objects. Organizational structures such as layers, groups, and blocks are objects. The drawing displays such as view and viewport are objects. Even the drawing and the AutoCAD application are considered objects.

Please send us your comment about this page

Introduction >

Overview of AutoCAD Visual Basic for Applications (VBA) Interface

Microsoft VBA is an object-oriented programming environment designed to provide rich development capabilities similar to those of Visual Basic 6 (VB). The main difference between VBA and VB is that VBA runs in the same process space as AutoCAD, providing an AutoCAD-intelligent and very fast programming environment.

VBA also provides application integration with other VBA-enabled applications. This means that AutoCAD, using other application object libraries, can be an Automation controller for other applications such as Microsoft Word or Excel.

The standalone development editions of Visual Basic 6, which must be purchased separately, complement AutoCAD VBA with additional components, such as an external database engine and report-writing capabilities.

There are four advantages to implementing VBA for AutoCAD:

VBA and its environment are easy to learn and use.

VBA runs in-process with AutoCAD. This translates to very fast program execution.

Dialog box construction is quick and effective. This allows developers to prototype applications and quickly receive feedback on designs.

Projects can be standalone or embedded in drawings. This choice allows developers great flexibility in the distribution of their applications.

Note Microsoft has not promised to provide 64-bit VBA SDK libraries (.dll). Subsequently, 64-bit AutoCAD can no longer run VBA as an in-proc component; VBA components now run as 32-bit out-of-process COM components, and provides a stopgap arrangement for 64-bit AutoCAD VBA users. This arrangement might require a few changes to existing VBA code. This

stopgap provision would be deprecated in future versions of AutoCAD and it is advisable for the users to port their exisiting VBA code to VB. NET. Topics in this section

How VBA Is Implemented in AutoCAD

Please send us your comment about this page

Introduction > Overview of AutoCAD Visual Basic for Applications (VBA) Interface >

How VBA Is Implemented in AutoCAD

VBA sends messages to AutoCAD by the AutoCAD ActiveX Automation interface. AutoCAD VBA permits the VBA environment to run simultaneously with AutoCAD and provides programmatic control of AutoCAD through the ActiveX Automation interface. This coupling of AutoCAD, ActiveX Automation, and VBA provides an extremely powerful interface not only for manipulating AutoCAD objects, but for sending data to or retrieving data from other applications.

There are three fundamental elements that define ActiveX and VBA programming in AutoCAD.The first is AutoCAD itself, which has a rich set of objects that encapsulates AutoCAD entities, data, and commands. Because AutoCAD was designed as an open-architecture application with multiple levels of interface, familiarity with AutoCAD programmability is highly desirable in order to use VBA effectively. If you've used AutoLISP to control AutoCAD programmatically, you already have a good understanding of the AutoCAD facilities. However, you will find the VBA object-based approach to be quite different from that of AutoLISP.

The second element is the AutoCAD ActiveX Automation interface, which establishes messages (communication) with AutoCAD objects.Programming in VBA requires a fundamental understanding of ActiveX Automation. A description of the AutoCAD ActiveX Automation interface can be found in the ActiveX and VBA Reference. Even the experienced VB programmer will find the AutoCAD ActiveX Automation interface invaluable for understanding and developing AutoCAD VBA applications.

The third element is the VBA programming environment, which has its own set of objects, keywords, constants, and so forth that provides program flow, control, debugging, and execution. Microsoft's own extensive Help for VBA is included with the AutoCAD VBA Help and is accessible from the VBA IDE by any of the

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download