Working with Civil3D 2010 Managed .Net API 101 – 1

As spring settles in with the beautiful sun outside, I sit at my office sick as a dog, or maybe its a sick as a swine nowadays! Anyway, I thought I would start a series to help any who wanted to work with Civil3D’s API. With Civil3D 2010, they have additional functionality to the Managed .Net API. Thus you don’t have to tie into Civil3D’s database using a COM method but rather Civil is a native system namespace. If I just lost you that is fine, just realize that Autodesk is working hard to provide a cleaner, more efficient way to work with programmatically.

Okay, enough talk. Let’s setup our Visual Studio Project.

Using Visual Studio 2005/2008 or Express, you would go to start a new Class Library Template. Name it TestCivil3DApplication.

When you click okay, a new Visual Studio project will be started. Go to your solution explorer and right click on the project name (TestCivil3DApplication) and choose properties. If Solution Explorer is not visible, Go to View>Solution Explorer.

There are a few settings we want to look at in our project’s properties.

First go to the Debug section, and tell it to start Civil3D when you are debugging the application.

This will allow us to debug our application since we are creating a class library (or DLL) we cannot run the application outside of a program.

Lastly, lets look at some references we want to add. Go to the References section of the project’s properties. In the bottom right corner click on the add button which will open a dialog box to add references to your project. Click on the Browse tab and go to your Civil3D Program directory (By default, C:\Program Files\AutoCAD Civil3D 2010). From there we are going to add 4 references:

  • acdbmgd.dll
    • This is the reference that will let us work with AutoCAD’s database.
  • acmgd.dll
    • This is the reference that will let us interact with the AutoCAD application.
  • AecBaseMgd.dll
    • This is the base managed system that Civil3D is built off of.
  • AeccDbMgd.dll
    • Civil3D’s Base reference.

Finally, we don’t to copy these references locally. We don’t need to because we are going to having our application work in Civil3D which already has these references loaded. If we create local copies, we could run into versioning issues among other things. So select all four newly added references and in the properties window (View>Properties) select the Copy Local parameter and set it to False.

Now that we have our project setup, we will look at doing some coding next.

BTW, Would you like a class in AU to be about this? If so, let me know.

7 comments

  1. Matt Kolberg says:

    Just in case someone reading tries this, if you’re using VS Express, you will not be able to specify the debug application, thus you won’t be able to debug at runtime. You need to pay for VS to do this.

    Matt

  2. Matt – there are “workarounds” available on the net that will allow VS Express to debug.

  3. Matt,

    It is very possible, just requires some ‘tweaking’. Kean covers this in his blog here:
    http://through-the-interface.typepad.com/through_the_interface/2006/07/debugging_using.html

  4. Matt Kolberg says:

    Thanks for the workaround. Seems like a trick 🙂 Like we’re getting away with something.

    Matt

  5. You kinda are 😉
    However, this is a widely publicized ‘workaround’ so no breaking the law or anything.

    Besides, there is still a lot of functionality that does not exist in Express although I wish they had Express when I started.