Chapter 2 "Hello World": creating a project
In this chapter, we will not use the ObjectARX Wizard to create a new project. We will use Visual Studio. NET to create a new class library project. Through this project, you can create a. NET dll file that can be loaded by AutoCAD. This dll file will add a new command named "HelloWorld" to AutoCAD. After you run this command, the "Hello World" text is displayed on the AutoCAD command line.
1) Start Visual Studio. NET and select "File> New> Project" (File> New> Project ). In the Create Project dialog box, select Visual Basic project as the project type, select the class library template, enter Lab1 in the Project Name box, and select the project storage location. Click OK to create a project.
2) In the Class1.vb file of the project, a public class "Class1" has been automatically created by the system. Next, add the command to this class. To add commands, you must use AutoCAD. NET to host the encapsulation class. These managed encapsulation classes are included in two managed modules. To add references to these two managed modules, right-click "Reference" and select "add reference ". In the Add reference dialog box that appears, select Browse ". In the select component dialog box, select the installation directory of AutoCAD 2006 (C: Program FilesAutoCAD 2006), and find "acdbmgd. dll "and then select and open it. Select Browse again, find acmgd. dll in the installation directory of AutoCAD 2006, and open it. After these two components are added, click "OK" in the "add reference" dialog box. As their names indicate, acdbmgd. dll contains the ObjectDBX hosting class, while acmgd. dll contains the AutoCAD hosting class.
3) use the Object Browser (Visual Studio. NET's "View> other Windows> Object Browser" menu item) to browse the classes provided by the added two managed modules. Expand the "AutoCAD. NET Managed Wrapper" Object (displayed as acmgd In the Object Browser), and we will use the class in this object throughout the tutorial. In this chapter, we will use an instance of the "Autodesk. AutoCAD. EditorInput. Editor" class to display text in the AutoCAD command line. Expand "ObjectDBX. NET Managed Wrapper "Object (displayed as acdbmgd In the Object Browser ), the classes in this object will be used to access and edit entities in the AutoCAD Drawing (this part will be described in later sections ).