AutoCAD 2006 VBA (eBook)

A Programmer's Reference

(Autor)

eBook Download: PDF
2006 | 2nd ed.
XXXII, 744 Seiten
Apress (Verlag)
978-1-4302-0069-7 (ISBN)

Lese- und Medienproben

AutoCAD 2006 VBA -  Joe Sutphin
Systemvoraussetzungen
99,99 inkl. MwSt
  • Download sofort lieferbar
  • Zahlungsarten anzeigen
* Second Edition of the comprehensive and highly respected guide to the AutoCAD VBA language.

* Suitable for all skill levels, novice and advanced power users.

* A complete reference for the AutoCAD 2006 object model, it shows you how to connect to other VBA-enabled applications, such as Word and Excel, and use the using the Win32 API to further extend your applications.



Joe Sutphin's background includes more than 20 years in the machinery manufacturing industry. He has more than 14 years of computer-aided design experience with more than eight years of AutoCAD-specific experience. Joe is an Autodesk registered developer, and his work has appeared in the pages of Cadence and Cadalyst magazines. He has been programming for over 10 years, with the last five years spent focusing on Visual Basic. In 1998, he collaborated with Microsoft on a Visual Basic application case study.
This book will help you take full advantage of the Visual Basic for Applications programming environment within AutoCAD 2006. Whether you want to automate routine tasks, or create sophisticated applications or design that can be generated programmatically, this book will empower you to make AutoCAD work for you.This book is also suitable if you're a power user who wants to make use of the advanced features of AutoCAD 2006 VBA, and you need a fast reference for the full AutoCAD object model. You'll learn to run Autodesk design tasks in the embedded VBA environment. This book is loaded with source code examples, and gives you no matter your skill level the necessary tools to accomplish your AutoCAD 2006 automation tasks.

Joe Sutphin's background includes more than 20 years in the machinery manufacturing industry. He has more than 14 years of computer-aided design experience with more than eight years of AutoCAD-specific experience. Joe is an Autodesk registered developer, and his work has appeared in the pages of Cadence and Cadalyst magazines. He has been programming for over 10 years, with the last five years spent focusing on Visual Basic. In 1998, he collaborated with Microsoft on a Visual Basic application case study.

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
Controlling the Drawing Space 167
The ModelSpace and PaperSpace Collections 168
Creating Objects 169
Circular Objects 169
Line Objects 174
Other Objects of Interest 186
Summary 196
Chapter 9 Creating 3-D Objects 197
Understanding the 3DSolid Object 197
Creating Simple Solid Objects 198
The Box 198
The Cone 200
The Cylinder 201
The Sphere 203
The Torus 204
The Wedge 205
Creating Elliptical 3-D Objects 207
The Elliptical Cone 207
The Elliptical Cylinder 209
Creating Extruded and Revolved Objects 210
The Extruded Solid 211
The Extruded Solid Along a Path 213
The Revolved Solid 215
Editing Solids 218
Boolean Operations 218
Interference Operation 220
Slicing Solids 222
Analyzing Solids: Mass Properties 225
Summary 227
Chapter 10 Editing Objects 228
Editing with Methods 228
Copying Objects 229
Deleting Objects 229
Exploding Objects 230
Highlighting Entities 231
Mirroring Objects 232
Moving Objects 235
Offsetting Objects 236
Rotating Objects 238
Scaling Objects 241
Object Arrays 242
Editing with Properties 246
Changing an Object’s Color 246
Changing an Object’s TrueColor Property 248
Changing an Object’s Color Properties 249
Changing an Object’s Layer 249
Changing an Object’s Linetype 250
Changing an Object’s Visibility 251
The UpdateMethod 252
Summary 252
Chapter 11 Dimensions and Annotations 253
Working with Dimensions 253
Using the DimStyle Object 253
Setting Dimension Styles 254
Using the CopyFromMethod 254
Using Dimension Styles 255
Creating Dimensions 257
Using the Tolerance Object 267
Working with Annotations 270
Using the TextStyle Object 270
Creating TextStyle Objects 270
Using a TextStyle 276
Adding Annotations 278
Using the Leader Object 278
Summary 280
Chapter 12 Selection Sets and Groups 281
Selection Sets 281
Adding a SelectionSet Object 281
Accessing and Iterating Selection Sets 282
Selecting Entities 283
Adding and Removing Items 295
The Clear, Delete, and EraseMethods 298
The PickFirstSelectionSet Property 299
Groups 300
Adding a Group Object 301
Accessing and Iterating Groups 301
Adding and Removing Items 302
The DeleteMethod 304
Summary 305
Chapter 13 Blocks, Attributes, and External References 306
Blocks and Block References 307
Accessing Block Objects 309
Creating Blocks 310
Defining and Manipulating Blocks 315
Using MInsertBlock Objects 322
Using External References 326
Attributes 331
Creating Attributes 331
Manipulating Attribute References 336
Summary 341
Chapter 14 Views and Viewports 342
Views 342
Creating a View 343
Setting a View as Current 345
Deleting a View 345
Viewports 346
The Model-Space Viewport 346
The Paper-Space Viewport 352
Summary 357
Chapter 15 Layout and Plot Configurations 358
The Plot Object 358
Plotting Your Drawing 359
Plot Configurations 364
Controlling Plot Parameters 368
Summary 375
Chapter 16 Controlling Menus and Toolbars 376
The MenuGroups Collection 377
Loading Menu Groups 377
The MenuGroup Object 380
Saving Menu Groups 382
Unloading Menu Groups 383
Accelerator Keys 383
Changing the Menu Bar 383
Editing Menus 390
Editing Toolbars 397
Summary 403
Chapter 17 Drawing Security 404
Digital Signatures 404
The Action Property 405
The Algorithm Property 406
The Issuer Property 406
The ProviderName Property 407
The SerialNumber Property 407
The Subject Property 407
The TimeServer Property 408
Password Protection 408
Summary 410
Chapter 18 Using the Windows API 411
Declarations 411
Windows Data Structures 412
Visual Basic-to-DLL Calling Conventions 412
Specifying the Library 413
The Major Windows DLLs 414
Working with Windows API Procedures That Use Strings 414
Passing Arguments by Value or by Reference 415
Learning by Example 415
Summary 422
Chapter 19 Connecting to External Applications 423
Making the Connection 423
Connecting to Microsoft Excel 425
Creating a New Workbook 425
Creating a New Worksheet 425
Accessing a Worksheet 426
Writing and Reading Cells 426
Saving and Exiting Excel 426
Connecting to Microsoft Word 427
Creating a New Document 427
Adding Text to the Document 427
Setting Page Orientation 427
Setting Margins 427
Setting the Document Header and Footer 428
Saving and Exiting Word 428
Connecting to a Microsoft Access Database 428
Connecting to a Database File 428
Retrieving a Set of Records 429
Writing Values to the Database File 430
Closing the Connection 430
Working with Other Databases 430
Connectivity Automation Objects 431
Advanced Database Issues 431
Working with Services and Other APIs 431
Summary 433
Chapter 20 Creating Tables 434
The AddTable Method 434
The RegenerateTableSuppressed Property 435
The GetText Method 435
The SetText Method 436
The GetTextHeight Method 437
The SetTextHeight Method 438
The InsertRows Method 439
The InsertColumns Method 440
Putting It All Together 442
Summary 445
Chapter 21 The SummaryInfo Object 446
Overview 447
Properties 447
The Author Property 447
The RevisionNumber Property 448
The Subject Property 448
The Title Property 449
Adding Custom SummaryInfo 449
The AddCustomInfoMethod 449
The GetCustomByKeyMethod 450
The NumCustomInfoMethod 451
The GetCustomByIndexMethod 451
The RemoveCustomByKeyMethod 452
The RemoveCustomByIndexMethod 452
The SetCustomByKeyMethod 453
The SetCustomByIndexMethod 453
Summary 454
Chapter 22 An Illustrative VBA Application 455
Start Building the Application 456
Writing the Code 456
Initial Declarations 456
Create a Session of Microsoft Word 457
Create a New Document in Word 458
Create a Table with the Word Document 458
Create Column Headings 458
Populate the Table with AutoCAD Layer Data 459
Helper Functions 460
Adjust the Fonts 462
Sort the Table 462
Autofit Column Text 463
Add Page Header and Footer 463
Print the Report 464
Summary 464
APPENDIX A AutoCAD Object Summary 465
AutoCAD Collections 465
The Application Property 466
The AcadObject Object 466
The AcadEntity Object 469
AcadDimension Object 472
AutoCAD Object Reference 475
Acad3DFace Object 475
Acad3DPolyline Object 477
Acad3DSolid Object 478
AcadApplication Object 479
AcadApplication Object Properties 481
AcadApplication Object Events 482
AcadArc Object 483
AcadAttribute Object 484
AcadAttributeReference Object 486
AcadBlock Object 487
AcadBlockReference Object 494
AcadBlocks Collection 495
AcadCircle Object 496
AcadDatabase Object 497
AcadDictionaries Collection 500
AcadDictionary Object 501
AcadDim3PointAngular Object 502
AcadDimAligned Object 504
AcadDimAngular Object 509
AcadDimArcLength Object 510
AcadDimDiametric Object 515
AcadDimOrdinate Object 519
AcadDimRadial Object 522
AcadDimRadialLarge Object 526
AcadDimRotated Object 531
AcadDimStyle Object 535
AcadDimStyles Collection 536
AcadDocument Object 537
AcadDocuments Collection 543
AcadExternalReference Object 546
AcadFileDependency Object 547
AcadFileDependencies Object 547
AcadHatch Object 549
AcadGroups Collection 549
AcadHyperlink Object 552
AcadHyperlinks Collection 553
AcadIDPair Object 553
AcadLayer Object 554
AcadLayers Collection 555
AcadLayout and AcadPlotConfiguration Objects 556
AcadLayouts and AcadPlotConfigurations Collections 559
AcadLeader Object 560
AcadLine Object 562
AcadLineType Object 563
AcadLineTypes Collection 564
AcadMenuBar Collection 566
AcadMInsertBlock Object 569
AcadMText Object 571
AcadPlot Object 573
AcadPlotConfiguration Object 575
AcadPlotConfigurations Collection 575
AcadPoint Object 575
AcadPolygonMesh Object 577
AcadPolyline Object 579
AcadPopupMenu Object 581
AcadPopupMenus Collection 584
AcadToolbars Collection 632
AcadUCS Object 634
AcadUCSs Collection 635
AcadUtility Object 636
AcadViewports Collection 642
AcadViews Collection 643
AcadXRecord Object 644
AcadXline Object 644
AcCmColor Object 646
APPENDIX B AutoCAD Constants Reference 649
Ac3DPolylineType 649
AcActiveSpace 649
ACAD_LWEIGHT 649
AcAlignment 650
AcAlignmentPointAcquisition 651
AcAngleUnits 651
AcARXDemandLoad 652
AcAttachmentPoint 652
AcAttributeMode 652
AcBlockScaling 653
AcBooleanType 653
AcCellAlignment 653
AcCellEdgeMask 654
AcCellType 654
AcColor 655
AcColorMethod 656
AcCoordinateSystem 656
AcDimArcLengthSymbol 657
AcDimArrowheadType 657
AcDimCenterType 658
AcDimFit 658
AcDimFractionType 658
AcDimHorizontalJustification 659
AcDimLUnits 659
AcDimPrecision 659
AcDimTextMovement 660
AcDimToleranceJustify 660
AcDimToleranceMethod 660
AcDimUnits 661
AcDimVerticalJustification 661
AcDrawingAreaSCMCommand 662
AcDrawingAreaSCMDefault 662
AcDrawingAreaSCMEdit 662
AcDrawingDirection 663
AcDynamicBlockReferenceProperty 663
AcEntityName 663
AcExtendOption 664
cGradientPatternType 665
AcGridLineType 665
AcHatchObjectType 665
AcHatchStyle 666
AcHorizontalAlignment 666
AcInsertUnits 666
AcISOPenWidth 667
AcKeyboardAccelerato 668
cKeyboardPriority 668
AcLeaderType 668
AcLineSpacingStyle 668
AcLineWeight 669
AcLoopType 670
AcMenuFileType 670
AcMenuGroupType 670
AcMenuItemType 670
AcMLineJustification 671
AcOleQuality 671
AcPatternType 671
AcPlotPaperUnits 672
AcPlotPolicy 672
AcPlotRotation 672
AcPlotScale 672
AcPlotType 674
AcPolylineType 674
AcPolymeshType 674
AcPreviewMode 675
AcPrinterSpoolAlert 675
AcProxyImage 675
AcRegenType 675
AcRotationAngle 676
AcRowType 676
AcSaveAsType 677
AcSelect 677
AcSelectType 678
AcShadePlot 678
AcTableDirection 679
AcTableStyleOverrides 679
AcTextFontStyle 683
AcTextGenerationFlag 683
AcToolbarDockStatus 684
AcToolbarItemType 684
AcUnits 684
AcVerticalAlignment 685
AcViewportScale 685
AcViewportSplitType 686
AcWindowState 687
AcXRefDemandLoad 687
AcZoomScaleType 687
APPENDIX C System Variables 688
The GetVariable Method 688
The SetVariable Method 689
Index 714

Erscheint lt. Verlag 14.11.2006
Zusatzinfo XXXII, 744 p.
Verlagsort Berkeley
Sprache englisch
Themenwelt Mathematik / Informatik Informatik Software Entwicklung
Informatik Weitere Themen CAD-Programme
Technik Maschinenbau
Schlagworte AutoCAD • Autodesk • Automation • Computer-Aided Design (CAD) • Layers • Layout • Model
ISBN-10 1-4302-0069-3 / 1430200693
ISBN-13 978-1-4302-0069-7 / 9781430200697
Haben Sie eine Frage zum Produkt?
PDFPDF (Wasserzeichen)
Größe: 5,4 MB

DRM: Digitales Wasserzeichen
Dieses eBook enthält ein digitales Wasser­zeichen und ist damit für Sie persona­lisiert. Bei einer missbräuch­lichen Weiter­gabe des eBooks an Dritte ist eine Rück­ver­folgung an die Quelle möglich.

Dateiformat: PDF (Portable Document Format)
Mit einem festen Seiten­layout eignet sich die PDF besonders für Fach­bücher mit Spalten, Tabellen und Abbild­ungen. Eine PDF kann auf fast allen Geräten ange­zeigt werden, ist aber für kleine Displays (Smart­phone, eReader) nur einge­schränkt geeignet.

Systemvoraussetzungen:
PC/Mac: Mit einem PC oder Mac können Sie dieses eBook lesen. Sie benötigen dafür einen PDF-Viewer - z.B. den Adobe Reader oder Adobe Digital Editions.
eReader: Dieses eBook kann mit (fast) allen eBook-Readern gelesen werden. Mit dem amazon-Kindle ist es aber nicht kompatibel.
Smartphone/Tablet: Egal ob Apple oder Android, dieses eBook können Sie lesen. Sie benötigen dafür einen PDF-Viewer - z.B. die kostenlose Adobe Digital Editions-App.

Zusätzliches Feature: Online Lesen
Dieses eBook können Sie zusätzlich zum Download auch online im Webbrowser lesen.

Buying eBooks from abroad
For tax law reasons we can sell eBooks just within Germany and Switzerland. Regrettably we cannot fulfill eBook-orders from other countries.

Mehr entdecken
aus dem Bereich
Guide für effizientes Projektmanagement

von Friedrich V. Klopstock

eBook Download (2024)
tredition (Verlag)
19,99
Master the fundamentals of CNC machining, G-Code, 2D Laser machining …

von Samer Najia

eBook Download (2024)
Packt Publishing Limited (Verlag)
21,59