Hello,. netcadhello for. net cad Development

Source: Internet
Author: User

Hello,. netcadhello for. net cad Development

1. Development Overview

Using. NET to develop CAD, the versions earlier than CAD2005 are actually developed in ActiveX mode, not in the true sense. Net development. Since CAD2005, it has supported. NET development. the. NET Framework must be installed after CAD2005, proving that some of the functions of CAD are developed by. NET.

2. Development Environment Construction

2.1: Install CAD 2005 or later.

2.2: Install. NET development tools (such as ).

2.3: The development language can be C #, VB. NET of. NET, and C ++ hosted.

3. Use VB. NET to create a CAD-developed Hello Project

3.1: Create a project in VS2005, select the VB-class library, specify the name and path, and select "create solution directory ".

3.2: add reference to project, acdbmgd. dll and acmgd. dll, dll file path (C: \ Program Files (x86) \ AutoCAD 2007)

 


3.3: View-Object Browser, browsing the classes provided by the referenced assembly

3.4: add the Hello command

'The command to add must be imported into AutoCAD. NET hosted encapsulation class Imports Autodesk. autoCAD. applicationServicesImports Autodesk. autoCAD. editorInputImports Autodesk. autoCAD. runtimePublic Class Class1 add CAD commands. The CommandMethod attribute <CommandMethod ("Hello")> _ Public Sub Hello () 'provided by Runtime must be used. When the Hello command is executed in CAD, the Hello () function is called to obtain the Editor object of the current activity document, that is, the command line Dim ed As Editor = Application. documentManager. mdiActiveDocument. editor' call the WriteMessage function of the Editor object Show the text ed. WriteMessage on the command line ("Welcome to the world of. NET development AutoCAD! ") You can use the Application Class to access the Editor object of the Current CAD activity document. After creating an Editor instance, you can call its WriteMessage function to display the text content of End SubEnd Class in the command line.

3.5: Debugging

3.5.1: Project properties-debug-Start external programs and find the corresponding CAD version

3.5.2: run the NetLoad command to load the hosting program in CAD. Run the NetLoad command on the CAD command line. In the displayed dialog box "Select. NET assembly", select the compiled Hello. dll file.

3.5.3: Enter Hello in the CAD command line and press enter to execute the command. An "Unknown command" prompt will appear.

After research, the solution to this problem is: Stop debugging, view the "Copy local" attribute of acdbmgd. dll and acmgd. dll in project properties-reference, and change True to False.

Debug again.

I would like to thank Auto CAD VBA & VB. NET for its help in this book.

The content of this article is purely personal thoughts and feelings, due to the limited level, will inevitably have errors and omissions, welcome to criticize and correct (Mail: wuwt917@foxmail.com ).
View comments

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.