Thursday, December 29, 2011

Use COM Interoperability with .NET


Limitations and Using Interop (COM)
The .NET API does not expose all the functionality of AutoCAD Civil 3D, and it exposes less than the COM API. The following areas are not yet exposed in .NET:

  • Survey
  • Points
  • Surfaces
  • Sites and Parcels
  • Sections
  • Data Bands
  • Labels (except Alignment, Profile and Profile View labels)
In addition, there are some areas in implemented functionality that are not yet complete:

  • Pipes: interference checks (except interference check styles)
  • Corridors:
    • creating new corridors
    • adding baselines to corridors
    • creating or modifying corridor boundaries or masks
    • creating featurelines from polylines
    • computing cut and fill
    • setting the CodeSetStyle
If you require this functionality in your .NET project, you can use the corresponding COM objects.

To use AutoCAD Civil 3D COM APIs from .NET
  1. Create a .NET solution and project.
  2. Select Add Reference from the Project menu or Solution Explorer.
  3. On the COM tab, select the AutoCAD 2011 Type Library and the AutoCAD/ObjectDBX Common 18.0 Type Library.
  4. On the COM tab, selec the AEC Base 6.5 Application Library and the AEC Base 6.5 Object Library.
  5. On the COM tab, select the required Autodesk Civil Engineering 8.0 libraries for the functionality you require (for example, Land and UI Land for Alignments).
  6. Add the Autodesk.AutoCAD.Interop and Autodesk.AECC.Interop.Ui namespaces to your using or Imports statement.
NoteYou may see warnings about types not being found in various Autodesk.AutoCAD.Interop namespaces (warning type 1684). To disable these warnings, enter 1684 under Supress Warnings on the Build tab of the project’s properties.

In case libraries are not showed in the COM tab, they can be loaded by corresponding tlb files:

  • The AutoCAD 2010 type library, acax18enu.tlb, located at :\Program Files\Common Files\Autodesk Shared.
  • The AutoCAD/ObjectDBX Common 18.0 type library, axdb18enu.tlb, located at :\Program Files\Common Files\Autodesk Shared.
  • Autodesk Civil Engineering 8.0 libraries (for example, Land and UI Land), located at :\Program Files\Common Files\Autodesk Shared\Civil Engineering 80\Aecc*.tlb