| Contents | 6 |
---|
| About the Author | 23 |
---|
| About the Technical Reviewers | 24 |
---|
| Acknowledgments | 25 |
---|
| Introduction | 26 |
---|
| Chapter 1 The VBA Integrated Development Environment (VBAIDE) | 28 |
---|
| Visual Basic Concepts | 28 |
| Windows, Events, and Messages | 28 |
| Event-Driven vs. Procedural Programming | 29 |
| Developing Your Applications Interactively | 30 |
| Starting the Editor | 30 |
| Exploring the User Interface | 31 |
| The Project Explorer | 32 |
| The Code Window | 32 |
| The Properties Window | 33 |
| The Object and Procedure Boxes | 33 |
| The Immediate Window | 34 |
| The Options Dialog Box | 35 |
| Managing Projects | 36 |
| Project Structure | 36 |
| Creating,Opening, and Saving Projects | 37 |
| Adding, Saving, and Removing Files | 39 |
| Adding ActiveX Controls and Code Components | 40 |
| The Object Browser | 42 |
| Overview of AutoCAD VBA Commands | 49 |
| Summary | 49 |
| Chapter 2 Introduction to Visual Basic Programming | 50 |
---|
| Variables | 50 |
| Declaring Variables | 50 |
| Variable Scope and Lifetime | 52 |
| Data Types | 54 |
| Introduction to Arrays | 56 |
| Modules | 58 |
| UserForm | 58 |
| Standard | 58 |
| Class | 59 |
| Procedures | 59 |
| Calling Procedures | 61 |
| Passing Arguments to Procedures | 61 |
| Control Structures | 61 |
| Decision Structures | 61 |
| Select Case | 63 |
| Loop Structures | 64 |
| Do While ... Loop | 64 |
| Do ... Loop While | 65 |
| Do Until ... Loop and Do Loop ... Until | 65 |
| For ... Each ... Next | 67 |
| Nested Control Structures | 67 |
| Exiting a Control Structure | 68 |
| Exiting a Sub or Function Procedure | 69 |
| With ... End With | 69 |
| Application Writing Techniques | 70 |
| Writing Statements on Multiple Lines | 70 |
| Combining Statements on a Single Line | 70 |
| Adding Comments to Your Code | 71 |
| Overview of Object-Oriented Programming | 71 |
| Objects and Classes | 71 |
| Object Data | 72 |
| Private Variables | 72 |
| Public Variables | 72 |
| An Object s Behavior | 72 |
| Debugging Basics | 73 |
| Summary | 80 |
| Chapter 3 Application Elements | 81 |
---|
| Designing a UserForm | 81 |
| Adding a UserForm to Your Application | 81 |
| Setting UserForm Properties | 82 |
| Adding a Control to a Form | 84 |
| Visual Basic ActiveX Controls | 86 |
| TextBox | 87 |
| ListBox | 88 |
| CheckBox | 88 |
| OptionButton | 89 |
| ToggleButton | 89 |
| Frame | 90 |
| CommandButton | 90 |
| Additional ActiveX Controls | 90 |
| TabStrip | 90 |
| MultiPage | 91 |
| ScrollBar | 91 |
| SpinButton | 91 |
| Image | 91 |
| Summary | 92 |
| Chapter 4 AutoCAD Events | 93 |
---|
| Application-Level Events | 93 |
| Document-Level Events | 96 |
| The BeginCommand and EndCommand Events | 97 |
| The BeginOpen and EndOpen Events | 98 |
| The BeginClose and BeginDocClose Events | 98 |
| The Activate and Deactivate Events | 99 |
| The BeginSave and EndSave Events | 99 |
| Object-Level Events | 99 |
| Summary | 100 |
| Chapter 5 User Preferences | 101 |
---|
| Getting and Setting Support Path(s) | 103 |
| Controlling Cursor Size | 104 |
| Getting and Setting the AutoSaveInterval Property | 104 |
| Getting and Setting the Drawing Template File Path | 105 |
| Getting and Setting the Printer Support Path | 105 |
| Getting and Setting the File SaveAs Type | 106 |
| Enabling and Disabling the Startup Dialog Box | 108 |
| Saving and Retrieving Personal Preferences | 109 |
| User Preferences Changes in AutoCAD 2004 | 110 |
| Summary | 111 |
| Chapter 6 Controlling Layers and Linetypes | 112 |
---|
| Layers | 112 |
| Accessing Layers | 113 |
| Iterating Layers | 113 |
| Checking for Existing Layers | 114 |
| Creating a New Layer | 116 |
| Making a Layer Active | 117 |
| Turning a Layer On/Off | 119 |
| Setting a Layer to Be Frozen or Thawed | 120 |
| Locking/Unlocking a Layer | 120 |
| Making Layers Plottable | 121 |
| Renaming a Layer | 121 |
| Deleting a Layer | 122 |
| Getting a Layer s Handle | 123 |
| Layer Colors | 123 |
| Layer Linetypes | 124 |
| Layer Lineweights | 125 |
| Linetypes | 125 |
| Accessing Linetypes | 126 |
| Checking for Existing Linetypes | 127 |
| Loading a Linetype | 128 |
| Making a Linetype Active | 130 |
| Renaming a Linetype | 131 |
| Deleting a Linetype | 132 |
| Getting a Linetype s Handle | 133 |
| Changing a Linetype s Description | 133 |
| Scaling Linetypes | 134 |
| Summary | 135 |
| Chapter 7 User Interaction and the Utility Object | 136 |
---|
| Interface Methods | 136 |
| Input Methods and Dialogs | 136 |
| The PromptMethod | 138 |
| The InitializeUserInputMethod | 138 |
| Handling Errors in User Input | 153 |
| Conversion Methods | 154 |
| The AngleToRealMethod | 154 |
| The AngleToStringMethod | 155 |
| The DistanceToRealMethod | 155 |
| The RealToStringMethod | 156 |
| The AngleFromXAxisMethod | 157 |
| The PolarPointMethod | 158 |
| The TranslateCoordinatesMethod | 159 |
| Internet Methods | 161 |
| The IsURLMethod | 161 |
| The LaunchBrowserDialogMethod | 162 |
| The GetRemoteFileMethod | 164 |
| The IsRemoteFileMethod | 165 |
| The PutRemoteFileMethod | 165 |
| Summary | 166 |
| Chapter 8 Drawing Objects | 167 |
---|
|
|