Last year at AU, I presented a class about COM/.NET Interoperability. The class demonstrated how to use the Civil 3D COM API from a .NET Civil 3D extension. In general, you will want to use the .NET API when writing applications for Civil 3D, but there are times when a certain API is not available through .NET, and it is only exposed in COM. This was the case with AutoCAD Civil 3D 2011 and the Surfaces API back then. Today, the Surfaces API is available in .NET, and you should start planning to port your code.
It should be no secret, by now, that when I prepared my AU class, I knew the Surfaces .NET API will ship in the next release of Civil 3D.My ultimate goal in the presentation was to show how to encapsulate the surface functionality, so when the .NET API became available, the code was easy to port.
Now, the Surfaces .NET API is publicly available, so I ported the code, which you can download from here. The ‘SurfacesDemo’ solution contains two projects that implement the same set of commands. The COM project uses the Surfaces COM API. In the .NET sample, all COM related code and references have been removed, and the code has been ported to the .NET API.
If you do a delta of both projects, you will see how the majority of the changes happen in the surface wrapper class ‘CivilTinSurface’. This was the goal when the code was written; to insure an easy port of the code from COM to .NET.
It might be helpful to go through my AU class materials to understand the concepts I explained in the presentation. I posted the materials, which contain the source code in C# and VB.NET, as well as the class presentation and handout. I hope you enjoy reviewing the materials, and that you send me any feedback you might have.