Sutphin | AutoCAD 2006 VBA | E-Book | www.sack.de
E-Book

E-Book, Englisch, 744 Seiten

Sutphin AutoCAD 2006 VBA

A Programmer's Reference
2. ed
ISBN: 978-1-4302-0069-7
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark

A Programmer's Reference

E-Book, Englisch, 744 Seiten

ISBN: 978-1-4302-0069-7
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark



* 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.

Sutphin AutoCAD 2006 VBA jetzt bestellen!

Autoren/Hrsg.


Weitere Infos & Material


1;Contents;6
2;About the Author;23
3;About the Technical Reviewers;24
4;Acknowledgments;25
5;Introduction;26
6;Chapter 1 The VBA Integrated Development Environment (VBAIDE);28
6.1;Visual Basic Concepts;28
6.1.1;Windows, Events, and Messages;28
6.1.2;Event-Driven vs. Procedural Programming;29
6.1.3;Developing Your Applications Interactively;30
6.2;Starting the Editor;30
6.3;Exploring the User Interface;31
6.3.1;The Project Explorer;32
6.3.2;The Code Window;32
6.3.3;The Properties Window;33
6.3.4;The Object and Procedure Boxes;33
6.3.5;The Immediate Window;34
6.3.6;The Options Dialog Box;35
6.4;Managing Projects;36
6.4.1;Project Structure;36
6.4.2;Creating,Opening, and Saving Projects;37
6.4.3;Adding, Saving, and Removing Files;39
6.4.4;Adding ActiveX Controls and Code Components;40
6.4.5;The Object Browser;42
6.4.6;Overview of AutoCAD VBA Commands;49
6.5;Summary;49
7;Chapter 2 Introduction to Visual Basic Programming;50
7.1;Variables;50
7.1.1;Declaring Variables;50
7.1.2;Variable Scope and Lifetime;52
7.1.3;Data Types;54
7.1.4;Introduction to Arrays;56
7.2;Modules;58
7.2.1;UserForm;58
7.2.2;Standard;58
7.2.3;Class;59
7.3;Procedures;59
7.3.1;Calling Procedures;61
7.3.2;Passing Arguments to Procedures;61
7.4;Control Structures;61
7.4.1;Decision Structures;61
7.4.2;Select Case;63
7.5;Loop Structures;64
7.5.1;Do While ... Loop;64
7.5.2;Do ... Loop While;65
7.5.3;Do Until ... Loop and Do Loop ... Until;65
7.5.4;For ... Each ... Next;67
7.6;Nested Control Structures;67
7.7;Exiting a Control Structure;68
7.8;Exiting a Sub or Function Procedure;69
7.8.1;With ... End With;69
7.9;Application Writing Techniques;70
7.9.1;Writing Statements on Multiple Lines;70
7.9.2;Combining Statements on a Single Line;70
7.9.3;Adding Comments to Your Code;71
7.10;Overview of Object-Oriented Programming;71
7.10.1;Objects and Classes;71
7.10.2;Object Data;72
7.10.3;Private Variables;72
7.10.4;Public Variables;72
7.10.5;An Object’s Behavior;72
7.10.6;Debugging Basics;73
7.11;Summary;80
8;Chapter 3 Application Elements;81
8.1;Designing a UserForm;81
8.1.1;Adding a UserForm to Your Application;81
8.1.2;Setting UserForm Properties;82
8.2;Adding a Control to a Form;84
8.3;Visual Basic ActiveX Controls;86
8.3.1;TextBox;87
8.3.2;ListBox;88
8.3.3;CheckBox;88
8.3.4;OptionButton;89
8.3.5;ToggleButton;89
8.3.6;Frame;90
8.3.7;CommandButton;90
8.4;Additional ActiveX Controls;90
8.4.1;TabStrip;90
8.4.2;MultiPage;91
8.4.3;ScrollBar;91
8.4.4;SpinButton;91
8.4.5;Image;91
8.5;Summary;92
9;Chapter 4 AutoCAD Events;93
9.1;Application-Level Events;93
9.2;Document-Level Events;96
9.2.1;The BeginCommand and EndCommand Events;97
9.2.2;The BeginOpen and EndOpen Events;98
9.2.3;The BeginClose and BeginDocClose Events;98
9.2.4;The Activate and Deactivate Events;99
9.2.5;The BeginSave and EndSave Events;99
9.3;Object-Level Events;99
9.4;Summary;100
10;Chapter 5 User Preferences;101
10.1;Getting and Setting Support Path(s);103
10.2;Controlling Cursor Size;104
10.3;Getting and Setting the AutoSaveInterval Property;104
10.4;Getting and Setting the Drawing Template File Path;105
10.5;Getting and Setting the Printer Support Path;105
10.6;Getting and Setting the File SaveAs Type;106
10.7;Enabling and Disabling the Startup Dialog Box;108
10.8;Saving and Retrieving Personal Preferences;109
10.9;User Preferences Changes in AutoCAD 2004;110
10.10;Summary;111
11;Chapter 6 Controlling Layers and Linetypes;112
11.1;Layers;112
11.1.1;Accessing Layers;113
11.1.2;Iterating Layers;113
11.1.3;Checking for Existing Layers;114
11.1.4;Creating a New Layer;116
11.1.5;Making a Layer Active;117
11.1.6;Turning a Layer On/Off;119
11.1.7;Setting a Layer to Be Frozen or Thawed;120
11.1.8;Locking/Unlocking a Layer;120
11.1.9;Making Layers Plottable;121
11.1.10;Renaming a Layer;121
11.1.11;Deleting a Layer;122
11.1.12;Getting a Layer’s Handle;123
11.1.13;Layer Colors;123
11.1.14;Layer Linetypes;124
11.1.15;Layer Lineweights;125
11.2;Linetypes;125
11.2.1;Accessing Linetypes;126
11.2.2;Checking for Existing Linetypes;127
11.2.3;Loading a Linetype;128
11.2.4;Making a Linetype Active;130
11.2.5;Renaming a Linetype;131
11.2.6;Deleting a Linetype;132
11.2.7;Getting a Linetype’s Handle;133
11.2.8;Changing a Linetype’s Description;133
11.2.9;Scaling Linetypes;134
11.3;Summary;135
12;Chapter 7 User Interaction and the Utility Object;136
12.1;Interface Methods;136
12.1.1;Input Methods and Dialogs;136
12.1.2;The PromptMethod;138
12.1.3;The InitializeUserInputMethod;138
12.1.4;Handling Errors in User Input;153
12.2;Conversion Methods;154
12.2.1;The AngleToRealMethod;154
12.2.2;The AngleToStringMethod;155
12.2.3;The DistanceToRealMethod;155
12.2.4;The RealToStringMethod;156
12.2.5;The AngleFromXAxisMethod;157
12.2.6;The PolarPointMethod;158
12.2.7;The TranslateCoordinatesMethod;159
12.3;Internet Methods;161
12.3.1;The IsURLMethod;161
12.3.2;The LaunchBrowserDialogMethod;162
12.3.3;The GetRemoteFileMethod;164
12.3.4;The IsRemoteFileMethod;165
12.3.5;The PutRemoteFileMethod;165
12.4;Summary;166
13;Chapter 8 Drawing Objects;167
13.1;Controlling the Drawing Space;167
13.1.1;The ModelSpace and PaperSpace Collections;168
13.2;Creating Objects;169
13.2.1;Circular Objects;169
13.2.2;Line Objects;174
13.2.3;Other Objects of Interest;186
13.3;Summary;196
14;Chapter 9 Creating 3-D Objects;197
14.1;Understanding the 3DSolid Object;197
14.2;Creating Simple Solid Objects;198
14.2.1;The Box;198
14.2.2;The Cone;200
14.2.3;The Cylinder;201
14.2.4;The Sphere;203
14.2.5;The Torus;204
14.2.6;The Wedge;205
14.3;Creating Elliptical 3-D Objects;207
14.3.1;The Elliptical Cone;207
14.3.2;The Elliptical Cylinder;209
14.4;Creating Extruded and Revolved Objects;210
14.4.1;The Extruded Solid;211
14.4.2;The Extruded Solid Along a Path;213
14.4.3;The Revolved Solid;215
14.5;Editing Solids;218
14.5.1;Boolean Operations;218
14.5.2;Interference Operation;220
14.5.3;Slicing Solids;222
14.6;Analyzing Solids: Mass Properties;225
14.7;Summary;227
15;Chapter 10 Editing Objects;228
15.1;Editing with Methods;228
15.1.1;Copying Objects;229
15.1.2;Deleting Objects;229
15.1.3;Exploding Objects;230
15.1.4;Highlighting Entities;231
15.1.5;Mirroring Objects;232
15.1.6;Moving Objects;235
15.1.7;Offsetting Objects;236
15.1.8;Rotating Objects;238
15.1.9;Scaling Objects;241
15.1.10;Object Arrays;242
15.2;Editing with Properties;246
15.2.1;Changing an Object’s Color;246
15.2.2;Changing an Object’s TrueColor Property;248
15.2.3;Changing an Object’s Color Properties;249
15.2.4;Changing an Object’s Layer;249
15.2.5;Changing an Object’s Linetype;250
15.2.6;Changing an Object’s Visibility;251
15.2.7;The UpdateMethod;252
15.3;Summary;252
16;Chapter 11 Dimensions and Annotations;253
16.1;Working with Dimensions;253
16.1.1;Using the DimStyle Object;253
16.1.2;Setting Dimension Styles;254
16.1.3;Using the CopyFromMethod;254
16.1.4;Using Dimension Styles;255
16.1.5;Creating Dimensions;257
16.1.6;Using the Tolerance Object;267
16.2;Working with Annotations;270
16.2.1;Using the TextStyle Object;270
16.2.2;Creating TextStyle Objects;270
16.2.3;Using a TextStyle;276
16.3;Adding Annotations;278
16.3.1;Using the Leader Object;278
16.4;Summary;280
17;Chapter 12 Selection Sets and Groups;281
17.1;Selection Sets;281
17.1.1;Adding a SelectionSet Object;281
17.1.2;Accessing and Iterating Selection Sets;282
17.1.3;Selecting Entities;283
17.1.4;Adding and Removing Items;295
17.1.5;The Clear, Delete, and EraseMethods;298
17.1.6;The PickFirstSelectionSet Property;299
17.2;Groups;300
17.2.1;Adding a Group Object;301
17.2.2;Accessing and Iterating Groups;301
17.2.3;Adding and Removing Items;302
17.2.4;The DeleteMethod;304
17.3;Summary;305
18;Chapter 13 Blocks, Attributes, and External References;306
18.1;Blocks and Block References;307
18.1.1;Accessing Block Objects;309
18.1.2;Creating Blocks;310
18.1.3;Defining and Manipulating Blocks;315
18.1.4;Using MInsertBlock Objects;322
18.1.5;Using External References;326
18.2;Attributes;331
18.2.1;Creating Attributes;331
18.2.2;Manipulating Attribute References;336
18.3;Summary;341
19;Chapter 14 Views and Viewports;342
19.1;Views;342
19.1.1;Creating a View;343
19.1.2;Setting a View as Current;345
19.1.3;Deleting a View;345
19.2;Viewports;346
19.2.1;The Model-Space Viewport;346
19.2.2;The Paper-Space Viewport;352
19.3;Summary;357
20;Chapter 15 Layout and Plot Configurations;358
20.1;The Plot Object;358
20.2;Plotting Your Drawing;359
20.3;Plot Configurations;364
20.4;Controlling Plot Parameters;368
20.5;Summary;375
21;Chapter 16 Controlling Menus and Toolbars;376
21.1;The MenuGroups Collection;377
21.1.1;Loading Menu Groups;377
21.2;The MenuGroup Object;380
21.2.1;Saving Menu Groups;382
21.2.2;Unloading Menu Groups;383
21.2.3;Accelerator Keys;383
21.2.4;Changing the Menu Bar;383
21.2.5;Editing Menus;390
21.2.6;Editing Toolbars;397
21.3;Summary;403
22;Chapter 17 Drawing Security;404
22.1;Digital Signatures;404
22.1.1;The Action Property;405
22.1.2;The Algorithm Property;406
22.1.3;The Issuer Property;406
22.1.4;The ProviderName Property;407
22.1.5;The SerialNumber Property;407
22.1.6;The Subject Property;407
22.1.7;The TimeServer Property;408
22.2;Password Protection;408
22.3;Summary;410
23;Chapter 18 Using the Windows API;411
23.1;Declarations;411
23.2;Windows Data Structures;412
23.3;Visual Basic-to-DLL Calling Conventions;412
23.4;Specifying the Library;413
23.5;The Major Windows DLLs;414
23.6;Working with Windows API Procedures That Use Strings;414
23.7;Passing Arguments by Value or by Reference;415
23.8;Learning by Example;415
23.9;Summary;422
24;Chapter 19 Connecting to External Applications;423
24.1;Making the Connection;423
24.2;Connecting to Microsoft Excel;425
24.2.1;Creating a New Workbook;425
24.2.2;Creating a New Worksheet;425
24.2.3;Accessing a Worksheet;426
24.2.4;Writing and Reading Cells;426
24.2.5;Saving and Exiting Excel;426
24.3;Connecting to Microsoft Word;427
24.3.1;Creating a New Document;427
24.3.2;Adding Text to the Document;427
24.3.3;Setting Page Orientation;427
24.3.4;Setting Margins;427
24.3.5;Setting the Document Header and Footer;428
24.3.6;Saving and Exiting Word;428
24.4;Connecting to a Microsoft Access Database;428
24.4.1;Connecting to a Database File;428
24.4.2;Retrieving a Set of Records;429
24.4.3;Writing Values to the Database File;430
24.4.4;Closing the Connection;430
24.4.5;Working with Other Databases;430
24.4.6;Connectivity Automation Objects;431
24.4.7;Advanced Database Issues;431
24.4.8;Working with Services and Other APIs;431
24.5;Summary;433
25;Chapter 20 Creating Tables;434
25.1;The AddTable Method;434
25.2;The RegenerateTableSuppressed Property;435
25.3;The GetText Method;435
25.4;The SetText Method;436
25.5;The GetTextHeight Method;437
25.6;The SetTextHeight Method;438
25.7;The InsertRows Method;439
25.8;The InsertColumns Method;440
25.9;Putting It All Together;442
25.10;Summary;445
26;Chapter 21 The SummaryInfo Object;446
26.1;Overview;447
26.2;Properties;447
26.2.1;The Author Property;447
26.2.2;The RevisionNumber Property;448
26.2.3;The Subject Property;448
26.2.4;The Title Property;449
26.3;Adding Custom SummaryInfo;449
26.3.1;The AddCustomInfoMethod;449
26.3.2;The GetCustomByKeyMethod;450
26.3.3;The NumCustomInfoMethod;451
26.3.4;The GetCustomByIndexMethod;451
26.3.5;The RemoveCustomByKeyMethod;452
26.3.6;The RemoveCustomByIndexMethod;452
26.3.7;The SetCustomByKeyMethod;453
26.3.8;The SetCustomByIndexMethod;453
26.4;Summary;454
27;Chapter 22 An Illustrative VBA Application;455
27.1;Start Building the Application;456
27.2;Writing the Code;456
27.2.1;Initial Declarations;456
27.2.2;Create a Session of Microsoft Word;457
27.2.3;Create a New Document in Word;458
27.2.4;Create a Table with the Word Document;458
27.2.5;Create Column Headings;458
27.2.6;Populate the Table with AutoCAD Layer Data;459
27.2.7;Helper Functions;460
27.2.8;Adjust the Fonts;462
27.2.9;Sort the Table;462
27.2.10;Autofit Column Text;463
27.2.11;Add Page Header and Footer;463
27.2.12;Print the Report;464
27.3;Summary;464
28;APPENDIX A AutoCAD Object Summary;465
28.1;AutoCAD Collections;465
28.1.1;The Application Property;466
28.1.2;The AcadObject Object;466
28.1.3;The AcadEntity Object;469
28.1.4;AcadDimension Object;472
28.2;AutoCAD Object Reference;475
28.2.1;Acad3DFace Object;475
28.2.2;Acad3DPolyline Object;477
28.2.3;Acad3DSolid Object;478
28.2.4;AcadApplication Object;479
28.2.5;AcadApplication Object Properties;481
28.2.6;AcadApplication Object Events;482
28.2.7;AcadArc Object;483
28.2.8;AcadAttribute Object;484
28.2.9;AcadAttributeReference Object;486
28.2.10;AcadBlock Object;487
28.2.11;AcadBlockReference Object;494
28.2.12;AcadBlocks Collection;495
28.2.13;AcadCircle Object;496
28.2.14;AcadDatabase Object;497
28.2.15;AcadDictionaries Collection;500
28.2.16;AcadDictionary Object;501
28.2.17;AcadDim3PointAngular Object;502
28.2.18;AcadDimAligned Object;504
28.2.19;AcadDimAngular Object;509
28.2.20;AcadDimArcLength Object;510
28.2.21;AcadDimDiametric Object;515
28.2.22;AcadDimOrdinate Object;519
28.2.23;AcadDimRadial Object;522
28.2.24;AcadDimRadialLarge Object;526
28.2.25;AcadDimRotated Object;531
28.2.26;AcadDimStyle Object;535
28.2.27;AcadDimStyles Collection;536
28.2.28;AcadDocument Object;537
28.2.29;AcadDocuments Collection;543
28.2.30;AcadExternalReference Object;546
28.2.31;AcadFileDependency Object;547
28.2.32;AcadFileDependencies Object;547
28.2.33;AcadHatch Object;549
28.2.34;AcadGroups Collection;549
28.2.35;AcadHyperlink Object;552
28.2.36;AcadHyperlinks Collection;553
28.2.37;AcadIDPair Object;553
28.2.38;AcadLayer Object;554
28.2.39;AcadLayers Collection;555
28.2.40;AcadLayout and AcadPlotConfiguration Objects;556
28.2.41;AcadLayouts and AcadPlotConfigurations Collections;559
28.2.42;AcadLeader Object;560
28.2.43;AcadLine Object;562
28.2.44;AcadLineType Object;563
28.2.45;AcadLineTypes Collection;564
28.2.46;AcadMenuBar Collection;566
28.2.47;AcadMInsertBlock Object;569
28.2.48;AcadMText Object;571
28.2.49;AcadPlot Object;573
28.2.50;AcadPlotConfiguration Object;575
28.2.51;AcadPlotConfigurations Collection;575
28.2.52;AcadPoint Object;575
28.2.53;AcadPolygonMesh Object;577
28.2.54;AcadPolyline Object;579
28.2.55;AcadPopupMenu Object;581
28.2.56;AcadPopupMenus Collection;584
28.2.57;AcadToolbars Collection;632
28.2.58;AcadUCS Object;634
28.2.59;AcadUCSs Collection;635
28.2.60;AcadUtility Object;636
28.2.61;AcadViewports Collection;642
28.2.62;AcadViews Collection;643
28.2.63;AcadXRecord Object;644
28.2.64;AcadXline Object;644
28.2.65;AcCmColor Object;646
29;APPENDIX B AutoCAD Constants Reference;649
29.1;Ac3DPolylineType;649
29.2;AcActiveSpace;649
29.3;ACAD_LWEIGHT;649
29.4;AcAlignment;650
29.5;AcAlignmentPointAcquisition;651
29.6;AcAngleUnits;651
29.7;AcARXDemandLoad;652
29.8;AcAttachmentPoint;652
29.9;AcAttributeMode;652
29.10;AcBlockScaling;653
29.11;AcBooleanType;653
29.12;AcCellAlignment;653
29.13;AcCellEdgeMask;654
29.14;AcCellType;654
29.15;AcColor;655
29.16;AcColorMethod;656
29.17;AcCoordinateSystem;656
29.18;AcDimArcLengthSymbol;657
29.19;AcDimArrowheadType;657
29.20;AcDimCenterType;658
29.21;AcDimFit;658
29.22;AcDimFractionType;658
29.23;AcDimHorizontalJustification;659
29.24;AcDimLUnits;659
29.25;AcDimPrecision;659
29.26;AcDimTextMovement;660
29.27;AcDimToleranceJustify;660
29.28;AcDimToleranceMethod;660
29.29;AcDimUnits;661
29.30;AcDimVerticalJustification;661
29.31;AcDrawingAreaSCMCommand;662
29.32;AcDrawingAreaSCMDefault;662
29.33;AcDrawingAreaSCMEdit;662
29.34;AcDrawingDirection;663
29.35;AcDynamicBlockReferenceProperty;663
29.36;AcEntityName;663
29.37;AcExtendOption;664
29.38;cGradientPatternType;665
29.39;AcGridLineType;665
29.40;AcHatchObjectType;665
29.41;AcHatchStyle;666
29.42;AcHorizontalAlignment;666
29.43;AcInsertUnits;666
29.44;AcISOPenWidth;667
29.45;AcKeyboardAccelerato;668
29.46;cKeyboardPriority;668
29.47;AcLeaderType;668
29.48;AcLineSpacingStyle;668
29.49;AcLineWeight;669
29.50;AcLoopType;670
29.51;AcMenuFileType;670
29.52;AcMenuGroupType;670
29.53;AcMenuItemType;670
29.54;AcMLineJustification;671
29.55;AcOleQuality;671
29.56;AcPatternType;671
29.57;AcPlotPaperUnits;672
29.58;AcPlotPolicy;672
29.59;AcPlotRotation;672
29.60;AcPlotScale;672
29.61;AcPlotType;674
29.62;AcPolylineType;674
29.63;AcPolymeshType;674
29.64;AcPreviewMode;675
29.65;AcPrinterSpoolAlert;675
29.66;AcProxyImage;675
29.67;AcRegenType;675
29.68;AcRotationAngle;676
29.69;AcRowType;676
29.70;AcSaveAsType;677
29.71;AcSelect;677
29.72;AcSelectType;678
29.73;AcShadePlot;678
29.74;AcTableDirection;679
29.75;AcTableStyleOverrides;679
29.76;AcTextFontStyle;683
29.77;AcTextGenerationFlag;683
29.78;AcToolbarDockStatus;684
29.79;AcToolbarItemType;684
29.80;AcUnits;684
29.81;AcVerticalAlignment;685
29.82;AcViewportScale;685
29.83;AcViewportSplitType;686
29.84;AcWindowState;687
29.85;AcXRefDemandLoad;687
29.86;AcZoomScaleType;687
30;APPENDIX C System Variables;688
30.1;The GetVariable Method;688
30.2;The SetVariable Method;689
31;Index;714



Ihre Fragen, Wünsche oder Anmerkungen
Vorname*
Nachname*
Ihre E-Mail-Adresse*
Kundennr.
Ihre Nachricht*
Lediglich mit * gekennzeichnete Felder sind Pflichtfelder.
Wenn Sie die im Kontaktformular eingegebenen Daten durch Klick auf den nachfolgenden Button übersenden, erklären Sie sich damit einverstanden, dass wir Ihr Angaben für die Beantwortung Ihrer Anfrage verwenden. Selbstverständlich werden Ihre Daten vertraulich behandelt und nicht an Dritte weitergegeben. Sie können der Verwendung Ihrer Daten jederzeit widersprechen. Das Datenhandling bei Sack Fachmedien erklären wir Ihnen in unserer Datenschutzerklärung.