ActiveX and VBA Developer's Guide
Documentation Home
Introduction
Overview of AutoCAD ActiveX Technology
Overview of AutoCAD Visual Basic for Applications (VBA) Interface
How VBA Is Implemented in AutoCAD
Use the Microsoft .NET Framework
Dependencies and Restrictions
AutoCAD ActiveX and VBA Together
How This Guide Is Organized
For More Information
Sample Code
Migrate Automation Projects
New Objects
Changed Items
How to Migrate Projects
Getting Started with VBA
Understand Embedded and Global VBA Projects
Organize Your Projects with the VBA Manager
Load an Existing Project
Virus Alert
Unload a Project
Embed a Project into a Drawing
Extract a Project from a Drawing
Create a New Project
Save Your Project
Handle Your Macros
Use the Macros Dialog Box
Run a Macro
Edit a Macro
Step into a Macro
Set the Project Options
Edit Your Projects with the VBA IDE
View Project Information
Define the Components in a Project
Objects
Forms
Standard Modules
Class Modules
References
Add New Components
Import Existing Components
Edit Components
Use the Code Window
Use the UserForm Window
Name Your Project
Save Your Project
Reference Other VBA Projects
Set the VBA IDE Options
Editor
Editor Format
General
Docking
Perform an Introductory Exercise
More Information
AutoCAD VBA Project Terms
AutoCAD VBA Commands
ActiveX Automation Basics
Understand the AutoCAD Object Model
The Application Object
The Document Object
The Collection Objects
The Graphical and Nongraphical Objects
The Preferences, Plot, and Utility Objects
Use New AutoCAD Features
Access the Object Hierarchy
Reference Objects in the Object Hierarchy
Access the Application Object
Collection Objects
Access a Collection
Add a New Member to a Collection Object
Iterate through a Collection Object
Delete a Member of a Collection Object
Understand Properties and Methods
Understand Parent Objects
Locate the Type Library
Use Variants in Methods and Properties
What Is a Variant?
Use Variants for Array Data
Convert Arrays to Variants
Interpret Variant Arrays
Using Other Programming Languages
Convert the VBA Code to VB
Control the AutoCAD Environment
Open, Save, and Close Drawings
Set AutoCAD Preferences
Database Preferences
Control the Application Window
Control the Drawing Windows
Position and Size the Document Window
Use Zoom
Define a Zoom Window
Scale a View
Center Objects
Display Drawing Limits and Extents
Use Named Views
Use Tiled Viewports
Split the Active Viewport
Make Another Tiled Viewport Current
Update the Geometry in the Document Window
Reset Active Objects
Set and Return System Variables
Draw with Precision
Adjust Snap and Grid Alignment
Use Ortho Mode
Draw Construction Lines
Create Construction XLines
Query Construction XLines
Create Rays
Query Rays
Calculate Points and Values
Calculate Areas
Calculate a Defined Area
Prompt for User Input
GetString Method
GetPoint Method
GetKeyword Method
Control User Input
Access the AutoCAD Command Line
Work with No Documents Open
Import Other File Formats
Export to Other File Formats
Create and Edit AutoCAD Entities
Create Objects
Determine the Container Object
Create Lines
Create Curved Objects
Create Point Objects
Create Solid-Filled Areas
Work with Regions
Create Regions
Create Composite Regions
Unite Regions
Find the Intersection of Two Regions
Create Hatches
Create the Hatch Object
Associate a Hatch
Assign the Hatch Pattern Type and Name
Define the Hatch Boundaries
Work with Selection Sets
Create a Selection Set
Add Objects to a Selection Set
Define Rules for Selection Sets
Use Filter Lists to Define Selection Set Rules
Specify Multiple Criteria in a Selection Set Filter List
Add Complexity to Your Filter List Conditions
Use Wild-Card Patterns in Selection Set Filter Criteria
Filter for Extended Data
Display Information About a Selection Set
Remove Objects from a Selection Set
Edit Objects
Work with Named Objects
Purge Named Objects
Rename Objects
Copy Objects
Copy an Object to the Same Location
Copy Multiple Objects
Offset Objects
Mirror Objects
Array Objects
Create Polar Arrays
Create Rectangular Arrays
Move Objects
Move Objects Along a Vector
Rotate Objects
Delete Objects
Scale Objects
Transform Objects
Extend and Trim Objects
Explode Objects
Edit Polylines
Edit Splines
Edit Hatches
Edit Hatch Boundaries
Edit Hatch Patterns
Use Layers, Colors, and Linetypes
Work with Layers
Sort Layers and Linetypes
Create and Name Layers
Make a Layer Active
Turn Layers On and Off
Freeze and Thaw Layers
Lock and Unlock Layers
Assign Color to a Layer
Assign a Linetype to a Layer
Delete Layers
Work with Colors
Work with Linetypes
Make a Linetype Active
Rename Linetypes
Delete Linetypes
Change Linetype Descriptions
Specify Linetype Scale
Assign Layers, Colors, and Linetypes to Objects
Change an Object's Layer
Change an Object's Color
Change an Object's Linetype
Save and Restore Layer Settings
Understand How AutoCAD Saves Layer Settings
Use the LayerStateManager to Manage Layer Settings
Save Layer Settings
Restore Layer Settings
Export and Import Saved Layer Settings
Add Text to Drawings
Work with Text Styles
Create and Modify Text Styles
Assign Fonts
Use TrueType Fonts
Use Unicode and Big Fonts
Set Text Height
Set Obliquing Angle
Set Text Generation Flag
Use Line Text (Text)
Create Line Text
Format Line Text
Align Line Text
Change Line Text
Use Multiline Text (Mtext)
Create Multiline Text
Format Multiline Text
Use Unicode Characters, Control Codes, and Special Characters
Substitute Fonts
Specify an Alternative Default Font
Check Spelling
Dimensions and Tolerances
Dimensioning Concepts
Parts of a Dimension
Define the Dimension System Variables
Set Dimension Text Styles
Understand Leader Lines
Understand Associative Dimensions
Create Dimensions
Create Linear Dimensions
Create Radial Dimensions
Create Angular Dimensions
Create Ordinate Dimensions
Edit Dimensions
Override Dimension Text
Work with Dimension Styles
Create, Modify, and Copy Dimension Styles
Override the Dimension Style
Dimension in Model Space and Paper Space
Create Leaders and Annotation
Create Leader Lines
Add the Annotation to a Leader Line
Leader Associativity
Edit Leader Associativity
Edit Leaders
Use Geometric Tolerances
Create Geometric Tolerances
Edit Tolerances
Customize Toolbars and Menus
Understand the MenuBar and MenuGroups Collections
Load Menu Groups
Change the Menu Bar
Insert Menus in the Menu Bar
Remove Menus from the Menu Bar
Rearrange Menu Items on the Menu Bar
Create and Edit Pull-Down and Shortcut Menus
Create New Menus
Add New Menu Items to a Menu
Specify the Index Parameter
Specify the Label Parameter
Specify the Tag Parameter
Specify the Macro Parameter
Add Separators to a Menu
Assign an Accelerator Key to a Menu Item
Create Cascading Submenus
Delete Menu Items from a Menu
Explore the Properties of Menu Items
Create and Edit Toolbars
Create New Toolbars
Add New Toolbar Buttons to a Toolbar
Add Separators to a Toolbar
Define the Toolbar Button Image
Create Flyout Toolbars
Float and Dock Toolbars
Delete Toolbar Buttons from a Toolbar
Explore the Properties of Toolbar Items
Create Macros
Macro Characters Mapped to ASCII Equivalents
Macro Termination
Pause for User Input
Cancel a Command
Macro Repetition
Use of Single Object Selection Mode
Create Status-Line Help for Menu Items and Toolbar Items
Add Entries to the Right-Click Menu
Use Events
Understand the Events in AutoCAD
Guidelines for Event Handlers
Handle Application Level Events
Enable Application Level Events
Handle Document Level Events
Enable Document Level Events in Environments Other Than VBA
Code Document Level Events in Environments Other Than VBA
Code Document Level Events in VBA
Handle Object Level Events
Enable the Object Level Event
Work in Three-Dimensional Space
Specify 3D Coordinates
Define a User Coordinate System
Convert Coordinates
Create 3D Objects
Create Wireframes
Create Meshes
Create Polyface Meshes
Create Solids
Edit in 3D
Rotate in 3D
Array in 3D
Mirror Objects Along a Plane
Edit 3D Solids
Define Layouts and Plot
Model Space and Paper Space
Layouts
Layouts and Blocks
Plot Configurations
Layout Settings
Paper Size and Units
Adjust the Plot Origin
Set the Plot Area
Set the Plot Scale
Set the Lineweight Scale
Set the Plot Device
Viewports
Floating Viewports
Switch to a Paper Space Layout
Switch to the Model Space Layout
Create Paper Space Viewports
Change Viewport Views and Content
Scale Views Relative to Paper Space
Scale Pattern Linetypes in Paper Space
Use Shaded Viewports
Plot Your Drawing
Perform Basic Plotting
Plot from Model Space
Plot from Paper Space
Advanced Drawing and Organizational Techniques
Work with Raster Images
Attach and Scale a Raster Image
Manage Raster Images
Change Image File Paths
Name Images
Modify Images and Image Boundaries
Show and Hide Image Boundaries
Change Image Layer, Boundary Color, and Boundary Linetype
Change Image Scale, Rotation, Location, Width, and Height
Change Image Visibility
Modify Bitonal Image Color and Transparency
Adjust Image Brightness, Contrast, and Fade
Clip Images
Change the Clipping Boundary
Show and Hide the Clipping Boundary
Clip a raster image boundary
Use Blocks and Attributes
Work with Blocks
Define Blocks
Insert Blocks
Explode a Block Reference
Redefine a Block
Work with Attributes
Create Attribute Definitions and Attribute References
Edit Attribute Definitions
Extract Attribute Information
Use External References
Update Xrefs
Attach Xrefs
Overlay Xrefs
Detach Xrefs
Reload Xrefs
Unload Xrefs
Bind Xrefs
Clip Blocks and Xrefs
Demand Loading and Xref Performance
Assign and Retrieve Extended Data
Develop Applications with VBA
More VBA Terminology
Forms in VBA
Design and Run Mode
Add Controls to a Form
Change the Size and Placement of a Control
Use Formatting Controls
Change the Properties of a Control
Add Code to a Control
Display and Hide Forms
Load and Unload Forms
Modal Forms
Handle Errors
Define Application Error Types
Trap Runtime Errors
Respond to Trapped Errors
Respond to AutoCAD User Input Errors
Encrypt VBA Code Modules
Run a VBA Macro from a Toolbar or Menu
Automatically Load a VBA Project
Automatically Run a VBA Macro
Automatically Open the VBA IDE Whenever a Project Is Loaded
Work in a Zero Document State
Distribute Your Application
Distribute Visual Basic 6 Applications
64-bit Migration
AutoCAD Object Instantiation in VBA
Handling ObjectId
Appendix of 32-bit Methods
Interact with Other Applications and Windows APIs
Interact with Visual LISP Applications
Interact with Other Windows Applications
Reference the ActiveX Object Library of Other Applications
Create an Instance of the Other Application
Program with Objects from Other Applications
Quit the Other Application
Access Windows APIs from VBA
ActiveX/VBA Tutorial: Design the Garden Path
Check Your Environment
Define the Goal
Write the First Function
Get Input
Declare Variables
Enter the gpuser Subroutine
Draw the Path Outline
Draw the Tiles
Tie It All Together
Step Through the Code
Execute the Macro
Add a Dialog Box Interface
Create the Dialog Box
Use the Project Window to Navigate Your Project
Update the Existing Code
Add Code to the Dialog Box
Visual LISP and ActiveX/VBA Comparison
Visual LISP and ActiveX/VBA Comparison
Documentation Home