AutoCAD Civil 3D Customization

AutoCAD Civil 3D Customization

New Member
2 Posts
0 Kudos
Registered: ‎03-15-2009
Post 1 of 4

Trouble with C3d 2012 COM

310 Views, 3 Replies
02-12-2012 05:02 PM

Hello All,


I am having trouble getting the COM application objects, after trying a number of different methods that I managed to find in the (scant) literature and elsewhere.  I am using VB2010, w7 64 bit and C3D 64 bit. 


The code in question reads...


Imports Autodesk.AutoCAD.EditorInput

Imports Autodesk.AutoCAD.ApplicationServices

Imports Autodesk.AutoCAD.DatabaseServices

Imports Autodesk.AutoCAD.Interop

Imports Autodesk.AECC.Interop.UiLand

Imports Autodesk.Civil.ApplicationServices

Module Civil3DObjects


FriendConst ACAD_VERSION AsString = "AutoCAD.Application"

FriendConst CIVIL3D_VERSION AsString = "AeccXUiLand.AeccApplication.9.0"



Friend netDOC AsCivilDocument

Friend netEDITOR AsEditor



Friend comAcadApp As Autodesk.AutoCAD.Interop.IAcadApplication

Friend comAeccApp As Autodesk.AECC.Interop.UiLand.IAeccApplication

Friend comAeccDoc AsIAeccDocument

Friend comAeccDB As Autodesk.AECC.Interop.Land.IAeccDatabase

FriendFunction GetCOMobjects() AsBoolean


'returns true if successfull

        GetCOMobjects = False



'comAcadApp = TryCast(Application.AcadApplication, AcadApplication)


'comAeccApp = TryCast(comAcadApp.GetInterfaceObject(CIVIL3D_VERSION), AeccApplication)


'If comAeccApp Is Nothing Then


'    Throw New COMInstanceException("Unable to retrieve interface for Civil Application.", CIVIL3D_VERSION)


'End If





If IsNothing(comAcadApp) Then 

            comAcadApp = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication



Catch ex As System.Exception

            MsgBox("Cannot load AutoCAD Application")

Return False




IfNot comAcadApp IsNothing Then



                comAeccApp = comAcadApp.GetInterfaceObject(CIVIL3D_VERSION)

                comAeccDoc = comAeccApp.ActiveDocument

                comAeccDB = comAeccApp.ActiveDocument.Database

Catch ex As System.Exception

                MsgBox("Cannot load Civil3D Application")

Return False






Return True








Everything goes pear shaped at...


          comAeccApp = comAcadApp.GetInterfaceObject(CIVIL3D_VERSION)


         where CIVIL3D_VERSION = "AeccXUiLand.AeccApplication.9.0"


The project references are  shown in the attached image.



This has stumped me for a couple of days now and I am sure that I will feel like a goose for missing something simple.  Please help.





*Expert Elite*
4,618 Posts
919 Kudos
Registered: ‎07-22-2003
Post 2 of 4

Re: Trouble with C3d 2012 COM

02-12-2012 07:36 PM in reply to: AnthonyGraham7907

Using the GetInterfaceObject() method has the potential to try to use the wrong running instance of AutoCAD if there is more than one running. This was the case in older products, not sure about 2012 because we use the following code which always works for the running instance it is called in. (Which means I'm not sure why your code fails, it looks like it should be fine, just this method takes the place of the GetInterfaceObject())


comAeccApp = New IAeccApplicationClass()

 From there you can set the document and database objects.

Jeff_M, also a frequent Swamper
New Member
2 Posts
0 Kudos
Registered: ‎03-15-2009
Post 3 of 4

Re: Trouble with C3d 2012 COM

02-12-2012 08:55 PM in reply to: Jeff_M

Thanks Jeff,


I inserted the following code as a replacement for the GetInterfaceObject...


               Dim comAeccApp As New Autodesk.AECC.Interop.UiLand.AeccApplication

                comAeccApp = New AeccApplication




and got an error message saying that FDO.dll could not be found.  I found FDO.dll and updated the device path in C3D to look in the correct location (had to swap "...\FDO\BIN\" for "...\BIN\FDO") and the code ran through as it was meant.


Thanks again Jeff, you are a lifesaver.



720 Posts
88 Kudos
Registered: ‎08-25-2009
Post 4 of 4

Re: Trouble with C3d 2012 COM

02-14-2012 08:37 PM in reply to: AnthonyGraham7907



Unless you're using something that isn't exposed to .NET I would switch to VB.NET instead. The .NET API is 5-10 times faster than the COM API, and all new API work is being done on the .NET side.




Peter Funk

Autodesk, Inc.

Peter Funk
Autodesk, Inc.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!