I was wondering what the best method is to write DotNet tools for Civil3D and how to connect to C3D. I thought we could access every Civil object through DotNet but if I read the 2011 Civil Api Developers Guide it seems that there is only a minor part accessible, others like Surfaces and Corridors have to be done through COM references. So far I found that I need to reference:
AcDbMgd (AutoCAD), AcMgd (AutoCAD), AeccDbMgd (Civil3D)
and the COM references:
AeccXLandLib, AeccXUiLandLib, AutoCAD 2011 Type Library, AutoCAD/ObjectDBX Common 18.0 Type Library, Autodesk.AEC.Interop.Base, Autodesk.AEC.Interop.UIBase
I found some code to connect to the Civil document, which is not the same as the AutoCAD document, as far as I think.
Const ACAD_VER As String = "AutoCAD.Application.17.1"
Const CIVIL3D_VER As String = "AeccXUiLand.AeccApplication.5.0"
Public g_oCivil3D As Civil3DComUi.AeccApplication
Public g_oCivil3DDoc As Civil3DComUi.IAeccDocument
Public g_oCivil3DDb As Civil3DCom.IAeccDatabase
' Get Civil 3D (AeccApplication), Civil 3D document (AeccDocument) and database (AeccDatabase) objects.
Public Function Civil3DObtained() As Boolean
Dim oAcad As AcadCom.AcadApplication
oAcad = GetActiveObject(ACAD_VER)
g_oCivil3D = oAcad.GetInterfaceObject(CIVIL3D_VER)
If g_oCivil3D Is Nothing Then
MsgBox("Error creating " & CIVIL3D_VER & ", exit.")
Return False
End If
g_oCivil3DDoc = g_oCivil3D.ActiveDocument
g_oCivil3DDb = g_oCivil3D.ActiveDocument.Database
Return True
End Function
The code above is obviously not working because it checks for another Civil3D version while I work with Civil3D 2011. This is just example code I found in some AU class from 2007. But the Reference Guide is also advising to check for a specific Civil3D version. So, it is not possible to write some tool which will work in several Civil3D versions? I also found some code where it seems to be possible to read the current version and link to that.
m_civildoc = Autodesk.Civil.Applicationservices.CivilApplication.get_ActiveDocument
I think this way it is easier to connecto to a current Civil document. Am I thinking wrong here? Is there an easy (other) way ot access a Civil3D document?