AutoCAD Platform Customization VBA (PDF)

AutoCAD Platform Customization VBA (PDF)

Contents

Introduction

Chapter 1 • Understanding the AutoCAD VBA Environment What Makes Up an AutoCAD VBA Project?

What You’ll Need to Start
Determine If the AutoCAD VBA Environment Is Installed
Install the AutoCAD 2015 VBA Enabler
Getting Started with the VBA Editor .
Identifying the Components of a VBA Project
Navigating the VBA Editor Interface
Setting the VBA Environment Options
Managing VBA Programs
Creating a New VBA Project
Saving a VBA Project
Loading and Unloading a VBA Project
Embedding or Extracting a VBA Project. Executing VBA Macros
Accessing the AutoCAD VBA Documentation

Chapter 2 • Understanding Visual Basic for Applications

Learning the Fundamentals of the VBA Language
Creating a Procedure
Declaring and Using VariablesControlling the Scope of a Procedure or Variable
Continuing Long Statements
Adding Comments
Understanding the Differences Between VBA 32- and 64-Bit
Exploring Data Types Working with Objects
Accessing Objects in a Collection
Storing Data in Arrays Calculating Values with Math Functions and Operators
Manipulating Strings
Converting Between Data Types
Comparing Values
Testing Values for Equality
Comparing String Values Determining If a Value Is Greater or Less Than Another
Checking for Null, Empty, or Nothing Values
Validating Values
Grouping Comparisons
Conditionalizing and Branching Statements
Evaluating If a Condition Is Met
Testing Multiple Conditions
Repeating and Looping Expressions
Repeating Expressions a Set Number of Times
Stepping Through an Array or Collection
Performing a Task While or Until a Condition Is Met

Chapter 3 • Interacting with the Application and Documents Objects

Working with the Application .
Getting Information about the Current AutoCAD Session
Manipulating the Placement of the Application Window
Managing Documents
Working with the Current Drawing
Creating and Opening Drawings
Saving and Closing Drawings
Accessing Information about a Drawing
Manipulating a Drawing Window
Working with System Variables
Querying and Setting Application and
Document Preferences
Executing Commands
Exercise: Setting Up a Project
Creating the DrawingSetup Project
Creating and Saving a New Drawing from Scratch
Inserting a Title Block with the insert Command
Adding Drawing Properties
Setting the Values of Drafting-Related System Variables and Preferences

Chapter 4 • Creating and Modifying Drawing Objects

Understanding the Basics of a Drawing-Based Object
Accessing Objects in a Drawing
Working with Model or Paper Space
Creating Graphical Objects
Adding Straight Line Segments
Working with Curved Objects
Working with Polylines
Getting an Object in the Drawing
Modifying Objects Deleting Objects
Copying and Moving Objects
Rotating Objects
Changing Object Properties
Exercise: Creating, Querying, and Modifying Objects
Creating the DrawPlate Project
Creating the Utilities Class
Defi ning the CLI_DrawPlate Function
Running the CLI_DrawPlate Function
Exporting the Utilities Class

Chapter 5 • Interacting with the User and Controlling the Current View

Interacting with the User
Requesting Input at the Command Prompt
Providing Feedback to the User
Selecting Objects Selecting an Individual Object
Working with Selection Sets
Filtering Objects Performing Geometric Calculations
Calculating a Coordinate Value
Measuring the Distance Between Two Points
Calculating an Angle
Changing the Current View
Zooming and Panning the Current View
Working with Model Space Viewports
Creating and Managing Named Views
Applying Visual Styles
Exercise: Getting Input from the User to
Draw the Plate
Revising the CLI_DrawPlate Function
Revising the Utilities Class
Using the Revised drawplate Function

Chapter 6 • Annotating Objects

Working with Text
Creating and Modifying Text
Formatting a Text String Controlling Text with Text Styles
Dimensioning Objects
Creating Dimensions
Formatting Dimensions with Styles
Assigning a Dimension Style
Creating and Modifying Geometric Tolerances
Adding Leaders
Working with Multileaders
Creating and Modifying Legacy Leaders
Organizing Data with Tables
Inserting and Modifying a Table
Formatting Tables
Assigning a Table Style
Creating Fields
Exercise: Adding a Label to the Plate
Revising the CLI_DrawPlate Function
Revising the Utilities Class
Using the Revised drawplate Function

Chapter 7 • Working with Blocks and External References

Managing Block Defi nitions
Creating a Block Defi nition
Adding Attribute Defi nitions
Modifying and Redefi ning a Block Defi nition
Determining the Type of Block Defi nition
Inserting and Working with Block References
Inserting a Block Reference
Modifying a Block Reference
Accessing the Attributes of a Block
Working with Dynamic Properties
Managing External References
Working with Xrefs
Attaching and Modifying Raster Images
Working with Underlays
Listing File Dependencies.
Exercise: Creating and Querying Blocks
Creating the RoomLabel Project
Creating the RoomLabel Block Defi nition
Inserting a Block Reference Based on the RoomLabel Block Defi nition.
Prompting the User for an Insertion Point and a Room Number
Adding Room Labels to a Drawing
Creating the FurnTools Project
Moving Objects to Correct Layers
Creating a Basic Block Attribute Extraction Program
Using the Procedures of the FurnTools Project

Chapter 8 • Outputting Drawings

Creating and Managing Layouts
Creating a Layout
Working with a Layout
Controlling the Display of Layout Tabs
Displaying Model Space Objects with Viewports
Adding a Floating Viewport
Setting a Viewport as Current
Modifying a Floating Viewport
Controlling the Output of a Layout
Creating and Managing Named Page Setups
Specifying an Output Device and a Paper Size
Setting a Plot Style as Current
Defi ning the Area to Output
Changing Other Related Output Settings
Plotting and Previewing a Layout
Exporting and Importing File Formats
Exercise: Adding a Layout to Create a Check Plot
Creating the Layout Adding and Modifying a Plot Confi guration
Inserting a Title Block
Displaying Model Space Objects with a Viewport
Putting It All Together
Testing the CheckPlot Procedure

Chapter 9 • Storing and Retrieving

Custom Data
Extending Object Information
Working with Xdata
Defi ning and Registering an Application Name
Attaching Xdata to an Object
Querying and Modifying the Xdata Attached to an Object
Removing Xdata from an Object
Selecting Objects Based on Xdata
Creating and Modifying a Custom Dictionary
Accessing and Stepping through Dictionaries
Creating a Custom Dictionary
Storing Information in a Custom Dictionary
Managing Custom Dictionaries and Entries
Storing Information in the Windows Registry
Creating and Querying Keys and Values
Editing and Removing Keys and Values
Exercise: Storing Custom Values for the Room Labels Program
Attaching Xdata to the Room Label Block after Insertion
Revising the Main RoomLabel Procedure to Use the
Windows Registry
Testing the Changes to the RoomLabel Procedure
Persisting Values for the Room Label Procedure with a Custom Dictionary
Retesting the RoomLabel Procedure
Selecting Room Label Blocks

Chapter 10 • Modifying the Application and Working with Events

Manipulating the AutoCAD User Interface
Managing Menu Groups and Loading Customization Files
Working with the Pull-Down Menus and Toolbars
Controlling the Display of Other User-Interface Elements

Using External Custom Programs
Working with Events
Exercise: Extending the User Interface and Using Events
Loading the acp.cuix File
Specifying the Location of DVB Files
Adding the Document Events
Implementing an Application Event
Defi ning the AcadStartup Procedure
Testing the AcadStartup Procedure
Testing the Application and Document Events

Chapter 11 • Creating and Displaying User Forms

Adding and Designing a User Form
Adding a User Form to a VBA Project
Considering the Design of a User Form
Placing and Arranging Controls on a User Form
Placing a Control on a User Form
Deciding Which Control to Use
Grouping Related Controls
Managing Controls on a User Form
Changing the Appearance of a User Form or Control
Defi ning the Behavior of a User Form or Control
Displaying and Loading a User Form
Showing and Hiding a User Form
Loading and Unloading a User Form
Exercise: Implementing a User Form for the DrawPlate Project
Adding the User Form
Adding Controls to the User Form
Displaying a User Form
Implementing Events for a User Form and Controls Testing the User Form and Controls

Chapter 12 • Communicating with Other Applications

Referencing a Programming Library
Creating and Getting an Instance of an Object
Creating a New Instance of an Object
Getting an In-Memory Instance of an Object
Accessing a Drawing File from outside of AutoCAD
Working with Microsoft Windows
Accessing the Filesystem
Manipulating the Windows Shell
Using the Win32 API
Reading and Writing Text Files
Opening and Creating a File
Reading Content from a File
Writing Content to a File
Closing a File
Parsing Content in an XML File
Working with Microsoft Offi ce Applications
Exercise: Reading and Writing Data
Creating Layers Based on Data Stored in a Text File Searching for a File in the AutoCAD Support Paths
Adding Layers to a Drawing with the LoadLayers Procedure
Writing Bill of Materials to an External File
Using the FurnBOMExport Procedure

Chapter 13 • Handling Errors and Deploying VBA Projects

Catching and Identifying Errors
Recovering and Altering Execution after an Error
Getting Information About the Recent Error
Debugging a VBA Project
Debugging Through Messages
Using the VBA Editor Debug Tools
Deploying a VBA Project Loading a VBA Project
Specifying the Location of and Trusting a Starting a Macro with AutoLISP or a Command Macro Grouping Actions into a Single Undo
Protecting a Project
Exercise: Deploying the DrawPlate VBA Project
Stepping Through the BadCode VBA Project
Implementing Error Handling for the Utility ProceduresImplementing Error Handling and Undo Grouping for the Main Procedures Confi guring the AutoCAD Support and Trusted Paths


Preview of the document online



Download the ebook for free

More Reading

Post navigation

Leave a Comment

Leave a Reply

Your email address will not be published. Required fields are marked *