Читать книгу AutoCAD Platform Customization - Ambrosius Lee - Страница 10

Introduction
VBA in AutoCAD

Оглавление

VBA is often overlooked as one of the options available to extend the AutoCAD program. There is no additional software to purchase, but you must download and install a release-specific secondary component to use VBA. You can leverage VBA to perform simple tasks, such as inserting a title block with a specific insertion point, scale, and rotation and placing the block reference on a specific layer. To perform the same tasks manually, end users would have to first set a layer as current, choose the block they want to insert, and specify the properties of the block, which in the case of a title block are almost always the same.

The VBA programming language and AutoCAD Object library can be used to do the following:

• Create and manipulate graphical objects in a drawing, such as lines, circles, and arcs

• Create and manipulate nongraphical objects in a drawing, such as layers, dimension styles, and named views

• Perform mathematical and geometric calculations

• Request input from or display messages to the user at the Command prompt

• Interact with files and directories in the operating system

• Read from and write to external files

• Connect to applications that support ActiveX and COM

• Display user forms and get input from the end user

VBA code statements are entered into the Visual Basic Editor and stored in a DVB file. Once a VBA project has been loaded, you can execute the macros through the Macros dialog box. Unlike standard AutoCAD commands, macros cannot be executed from the Command prompt, but once executed, a macro can prompt users for values at the Command prompt or with a user form. It is possible to execute a macro from a command macro that is activated with a command button displayed in the AutoCAD user interface or as a tool on a tool palette.

AutoCAD Platform Customization

Подняться наверх