[Search tip detail and code files using keywords, tip number, author name, etc ]
    For tip to function correctly, you must ensure that the downloaded file name matches the file name
    displayed in the Rename File To field. Please rename downloaded files when necessary.
Create two simple AutoCAD commands
Tip# CLINIC0705 By Mike Tuersley On 01-Jul-2005
Rated By 1 users Downloaded : 465
Categories : Misc. User Tools, Programmer's Tools, LISP Code Modules
Software type : AutoCAD
Rename File To : HelloWorld.cs
Create two simple AutoCAD commands in c#

Welcome back! This month we're going to create the same two simple AutoCAD commands that we did last month, but this time in C# (pronounced C-sharp). As we go through this process, you may want to reference last month's column. As with last month's code, you can use any editor to create these commands -- including Windows' NotePad -- because no graphics are involved. I will use Microsoft's Visual Studio this month since I used SharpDevelop last month. This way you can compare the screen shots to see how similar both editors are.

For this article, we are going to recreate the classic "Hello World" example and throw the text into AutoCAD's command line and into an MText object just like last month. The code is derived from the Autodesk sample available within the AutoCAD 2006 install, AutoCAD 2006 ObjectARX toolkit and from the Autodesk website. The twist this month is we will use C# instead of VB.NET.

To begin, I will open Microsoft Visual Studio 2003. You can use Microsoft Visual Studio 2002, 2005 or the free beta Microsoft Visual Express C# 2005. All offer a very similar interface. At the start page, I will select Visual C# Projects and a Class Library (figure 1).Next I will add the references to our project just like with Visual Basic 6, VBA or last month's VB.NET project. As was the case last month, you will need to browse to AutoCAD's installed directory and select the managed libraries: ACDBMGD.DLL and ACMGD.DLL (figures 2 and 3). You do not select the AutoCAD 2006 type library in the COM tab! That would create a COM InterOp project similar to VB6-based programming. This project is going to be a .NET managed project, so you need to hook into the MGD files.



Average Rating:

User comments

Log In