AutoCAD_2007_C#二次开发(英文版)

  • 格式:pdf
  • 大小:9.04 MB
  • 文档页数:43

AutoCAD 2007 .NET API Training Labs -C# T able of Content$ AutoCAD 2007 .NET API Training Labs -C# Lab 1 -Hello World: Accessing ObjectARX .NET Wrappers Create your first AutoCAD managed application Connect to the AutoCAD Managed API -AcMgd.dll and AcDbMgd.dll Define your first command Test in AutoCAD Lab 2 -.NET AutoCAD Wizard and more with the Editor class The AutoCAD Managed Application Wizard Prompt for User Input Prompt to obtain a geometric distance Lab 3 -Database Fundamentals: Creating our Employee Object Add a command to create the Employee object Handling Exceptions -First look Transactions, Exception Handling and Dispose

Finish up the Employee object More about Transactions, Exception Handling and Dispose

Create a Layer for the Employee AutoCAD.NET API Training Labs

13

55

77

7 Add color to the Employee Create an explicit Employee Block Create a Block Reference for the new Employee block Visual Studio 2005 Using Keyword Extra credit questions: Lab 4 -Database Fundamentals Part 2: Adding Custom Data Create a custom structure in the Named Objects Dictionary Add an Xrecord to our new structure hold custom data Add an XRecord for each Employee Block Reference Instance Iterate Model Space to Count each Employee Object Notes about the completed lab Lab 5 -User Interaction: Prompts and Selection Prompts Block Attributes Modify CreateEmployee 0 for reuse

Modify CreateDivisionO for reuse Define the CREATE command to create the employee Selection Lab 6 -More User Interface: Adding Custom Data Custom Context Menu Modeless, Dockable Palette Window with Drag and Drop

Drag and Drop Support in the Modeless Form Entity Picking from a Modal Form Adding a page to the AutoCAD Optíons Dialog

nU41414lqJ

A崎

AU寸

RIMau?'?'

nununU4t呵,ιqJphd''?'n34lqdRd41414t44414,414144414t吨,

晶叮

4

呵,ι

呵,ι

呵,ι

呵,ι

呵,ι

吨,-

呵,ι

叮4

qdqJqJ

Extra credit: Setup the dialog so that the values within the Edit boxes automatically ref1ect the Shared Manager and Division strings in AsdkClass1. 37

Lab 7 -Handling Events in AutoCAD 七岁、去"uu U.~) ~ U L L 37

Events in C# 37

Delegates Described 37 C# += and -= statements 37 Handling AutoCAD Events in .NET 38 Lab: Using event handlers to control AutoCAD behavior 39 Setup the new project 39 Create the first Document event handler (callback) 39 Create the Database event handler (callback) 40 Create the second Document event handler (callback) 41 Create the commands to register/disconnect the event handlers 42 T est the project 43 Extra credit: Add an additional callback which is triggered when the EMPLOYEE block reference "Name" attribute has been changed by the user. 43

AutoCAD.NET API Training Labs 2 Lab 1 -Hello World: Accessing ObjectARX .NET Wrappers In this lab, we will use Visual Studio .NET and create a new Class Library project. This project will create a .NET dll that can be loaded into AutoCAD. It will add a new command to AutoCAD named "HelloWorld". When the user runs

the command, the text "Hello World" will be printed on the command line.

Create your first AutoCAD managed application 1) Launch Visual Studio and then select File> New> Project. In the New Project dialog select Visual C# Projects for the Project Type. Select "Class Libra印"template.Make the name "Lab1" and set the location where you want the project to be created. Select OK to create the projec

t.

2) If the solution explorer is not visible in visual studio, you may turn it on by going to "Vie旷menuand selecting "Solution Explorer". This view will allow us to browse through files in the project and add references to

managed or COM Interop assemblies. Open Class1.vb that was added by the NET wizard by double-clicking on it in the solution explorer.

3) In Class1.cs notice that a public class was automatically created. We will add our command to this class. To do this we need to use classes in the AutoCAD .NET managed wrappers. These wrappers are contained in two managed modules. To add references to these modules, right click on "References" in the solution Explorer and select "Add Reference". In the "Add Reference" dialog select "Browse气Select"Look in" and navigate to the

AutoCAD 2007 directory. (C:\Program Files\AutoCAD 2007\) Find "acdbmgd.dll" and select OK. Click "Browse"

again then select "acmgd.dll" and click OK.

Connect to the AutoCAD Managed API -AcMgd.dll and AcDbMgd.dll 4) Use the 0时ectBrowser to explore the classes available in these managed modules. (View >