Author Topic: Best method of connecting Civil3D  (Read 3308 times)

0 Members and 1 Guest are viewing this topic.

huiz

  • Swamp Rat
  • Posts: 919
  • Certified Prof C3D
Best method of connecting Civil3D
« on: December 04, 2010, 02:43:11 PM »
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.

Code: [Select]
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.

Code: [Select]
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?


The conclusion is justified that the initialization of the development of critical subsystem optimizes the probability of success to the development of the technical behavior over a given period.

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: Best method of connecting Civil3D
« Reply #1 on: December 04, 2010, 03:47:46 PM »
The last method gets the Managed CivilDoc, not the COM doc. You can also do:
Autodesk.Civil.Applicationservices.CivilApplication.ActiveDocument

For another (better?) method of getting the COM document, download the SincpacC3D Free Edition Source code. The method used in this negates the need for the Version strings. Although you will still need to create different builds for each version you want to support, due to the references.

The Corridors have been ported to .NET. Look in the Civil.Roadway namespace.

huiz

  • Swamp Rat
  • Posts: 919
  • Certified Prof C3D
Re: Best method of connecting Civil3D
« Reply #2 on: December 05, 2010, 03:38:26 AM »
That's a good tip, about the SincPac code! I've had a look at that before but forgot about it  :lol:
Thanks!

Corridors are indeed available in Net. Surfaces not, and for that I had a nice tool in mind. Well, have to play a bit with Net and Com till I am comfortable with everything :-)
The conclusion is justified that the initialization of the development of critical subsystem optimizes the probability of success to the development of the technical behavior over a given period.

joshua.modglin

  • Guest
Re: Best method of connecting Civil3D
« Reply #3 on: December 05, 2010, 07:05:50 PM »
For using the managed Civil 3D .Net API there is one other reference that should be added to your list:
AecBaseMgd

HTH,