Importing Civil 3D Namespace

Hi all,

I was wondering if it was possible to import the AutoCAD Civil 3D Namespace using IronPython in dynamo.

I have managed to import the standard AutoCAD namespace:

import sys
sys.path.append(r'C:\Program Files\Autodesk\AutoCAD 2016')
import clr
clr.AddReferenceToFile('acdbmgd.dll')
import Autodesk.AutoCAD

This works fine, when I try to import the civil namespace:

import sys
sys.path.append(r'C:\Program Files\Autodesk\AutoCAD 2016\C3D')
import clr
clr.AddReferenceToFile('AeccDbMgd.dll')

I receive this error:
IOError: [Errno 2] Could not load file or assembly ‘AeccDbMgd.dll’ or one of its dependencies. The specified module could not be found.

I’ve had a read around but it all goes well over my head, does anyone have any idea where I’m going wrong? Or if it is even possible? I’m assuming it is since it worked for standard AutoCAD.

I’m using Revit 2016 / CAD 2016 / Civil 2016. I have other versions of revit but only the 2016 version of Civil 3D so I can’t test to see if it’s a version issue. (I’ll get on to IT to get later versions installed!)

Thanks for reading,

TJ

Edit:
Not sure if either of these could help:

1 Like

Any luck over the years, same error.

The standard Dynamo for Civil 3D Python template should have this namespace loaded by default.

Indeed, loading the AeccDbMgd.dll from Dynamo for Civil 3D poses no problem. However, what if there is a need to control Civil 3D from Dynamo for Revit or Dynamo Sandbox?
Loading AutoCAD DLLs won’t be an issue from Dynamo for Revit or Dynamo Sandbox. Only the Civil 3D ones will encounter difficulties in finding the assembly.

Nevertheless, the subsequent challenge would be to manipulate a Civil 3D file through Civil 3D’s .NET API using a Python node from Dynamo for Revit or Dynamo Sandbox.
In this manner, a single Dynamo graph will be able to control both a Revit and a Civil 3D file simultaneously, reminiscent of how the CivilConnection package/CivilPython used to function. Unfortunately, it has reached its end of life.

Any ideas on this matter would be greatly appreciated.

The .NET Civil 3D API is an in-process API as far as I know. You could try a COM API but I am not sure it exists or functions well - if I recall correctly it has been deprecated some years back as it is much less robust. COM is the interop DLLs rather than the standard ones noted elsewhere, and I am not sure that Civil 3D has such a tool. ActiveX is likely a better fit here but again that’s another process and once again requires the interop DLLs.

Since you’re looking to interact with Civil 3D from a Revit context, Perhaps look into how Paolo Serra managed the Civil Connection as an example. GitHub - Autodesk/civilconnection: CivilConnection enables the exchange of information between Civil 3D, Dynamo and Revit.. Note that tool is not ‘end of life’ per say, but Paolo isn’t currently maintaining so there is no 2025 version yet it as (1) there are more robust options underway for sending data and geometry between the two applications now in the AEC data model and forge Data Exchange tools, and (2) doing so take a lot of time and no one has purchased a consulting engagement to do so. It is open sourced so you could certainly build things yourself. That said my belief is that the architecture involved sending commands to an add-in component built in Civil 3D which actively steered the Civil 3D instance rather than utilizing the interop APIs.

1 Like

Thank you for your response. I am going to take a look at the GitHub repository.