AutoCAD .NET
Developer’s Guide
Stephen Preton Autodesk Developer Technical Services Team (DevTech)
 
AutoCAD .NET Developers Guide
 Author:Stephen Preton Autodesk Developer Technical Services Team (DevTech)
Contents1 Introduction..................................................................................................................22
Topics in this section..............................................................................................................22Guide Organization.......................................................................................................................22Overview of the AutoCAD .NET API..............................................................................................22Components of the AutoCAD .NET API.........................................................................................23Overview of Microsoft Visual Studio..............................................................................................25Topics in this section..............................................................................................................25Which Edition of Microsoft Visual Studio to Use.........................................................................25Use COM Interoperability with .NET..........................................................................................26Dependencies and Restrictions.................................................................................................27For More Information.....................................................................................................................27Sample Code................................................................................................................................27Transition from ActiveX Automation to .NET.................................................................................28
2 Getting Started with Microsoft Visual Studio............................................................28
Topics in this section..............................................................................................................28Understand Microsoft Visual Studio Projects.................................................................................29Define the Components in a Project..............................................................................................29Class Modules....................................................................................................................30Forms.................................................................................................................................30References.........................................................................................................................30View Project Information...............................................................................................................30Work with Microsoft Visual Studio Projects....................................................................................31Procedures.........................................................................................................................31Topics in this section..............................................................................................................32Create a New Project.................................................................................................................32Procedures.........................................................................................................................32Open an Existing Project or Solution..........................................................................................35Procedures.........................................................................................................................35Save a Project or Solution.........................................................................................................36Procedures.........................................................................................................................36Work with Multiple Projects in a Solution...................................................................................37 Add a project to a solution..................................................................................................37Unload a project from a solution.........................................................................................37Procedures.........................................................................................................................37Edit an Existing Project or Solution................................................................................................37Topics in this section..............................................................................................................37 Add New Items..........................................................................................................................38Procedures.........................................................................................................................38Import Existing Items.................................................................................................................39Procedures.........................................................................................................................39Edit Items..................................................................................................................................40Procedures.........................................................................................................................40Topics in this section..............................................................................................................40Use the Code Window............................................................................................................40
 
Use the Windows Form Designer...........................................................................................42Procedures.........................................................................................................................42Use the Properties Window....................................................................................................43Procedures.........................................................................................................................44Rename a Project......................................................................................................................44Procedures.........................................................................................................................45 Add and Reference Other Projects............................................................................................45Procedures.........................................................................................................................46Set the Options for Microsoft Visual Studio................................................................................47Procedures.........................................................................................................................47Load an Assembly into AutoCAD..................................................................................................47Procedures.........................................................................................................................48 Access and Search Referenced Libraries (Object Browser)..........................................................48Procedures.........................................................................................................................49Exercises: Create Your First Project..............................................................................................50Topics in this section..............................................................................................................50Exercise: Create a New Project.................................................................................................50Exercise: Reference the AutoCAD .NET API Files.....................................................................51Exercise: Create a New Command............................................................................................51Exercise: Set the Target Framework for a Project......................................................................54Exercise: Build and Load a .NET Assembly in AutoCAD............................................................54Related AutoCAD Commands and Terminology............................................................................55Commands.........................................................................................................................55Terminology........................................................................................................................55More Information...........................................................................................................................56
3 Basics of the AutoCAD .NET API................................................................................57
Topics in this section..............................................................................................................57Understand the AutoCAD Object Hierarchy...................................................................................57Topics in this section..............................................................................................................58The Application Object...............................................................................................................58The Document Object................................................................................................................60The Database Object.................................................................................................................61Symbol Tables and Dictionaries..........................................................................................61VBA/ActiveX Cross Reference........................................................................................62The Graphical and Nongraphical Objects..................................................................................62The Collection Objects...............................................................................................................63Non-Native Graphical and Nongraphical Objects.......................................................................64 Access the Object Hierarchy.........................................................................................................65VB.NET..............................................................................................................................65C#.......................................................................................................................................65Topics in this section..............................................................................................................65Reference Objects in the Object Hierarchy................................................................................65VB.NET..............................................................................................................................65C#.......................................................................................................................................65VB.NET..............................................................................................................................66C#.......................................................................................................................................66VB.NET..............................................................................................................................66C#.......................................................................................................................................66VB.NET..............................................................................................................................66C#.......................................................................................................................................67VBA/ActiveX Code Reference.........................................................................................68 Access the Application Object....................................................................................................68VB.NET..............................................................................................................................68C#.......................................................................................................................................68VBA/ActiveX Code Reference.........................................................................................68Collection Objects.........................................................................................................................68
View on Scribd