Referencingn Civil3d dll files for development

Hey there, I am trying to reference the dll files
clr.AddReference(r"C:\Program Files\Autodesk\AutoCAD 2023\ACA\AecPropDataMgd.dll")

but its giving me this error:
FileNotFoundException: Could not load file or assembly ‘AecCoreMgd.dll’ or one of its dependencies. The specified module could not be found.
File name: ‘AecCoreMgd.dll’
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
at System.Reflection.Assembly.LoadFrom(String assemblyFile)
at Python.Runtime.AssemblyManager.LoadAssemblyFullPath(String name)
at Python.Runtime.CLRModule.AddReference(String name)

Any solutions?

Have you added this in a Dynamo for Civil 3D’s Python editor, or another Dynamo version/integration?

@abr0197236 Try it like this

import sys
import clr
sys.path.append(r'C:\Program Files\Autodesk\AutoCAD 2023\ACA')
clr.AddReference('AecPropDataMgd')
from Autodesk.Aec.PropertyData import *
from Autodesk.Aec.PropertyData.DatabaseServices import *
# rest of code
2 Likes

Same error

is this in Dynamo for Civil 3d’s Python editor or another context?

Hello,
sorry for the late reply.

No, its on VS code

And you’re trying to run it in VS code, or in Dynamo for Civil 3D?

No, im trying to run it in vs code

The AutoCAD API can only be accessed form inside an application which permits such; unless you are running VS code from within Revit or Civil 3D or something else that API is off limits.

Oh, thank you verymuch!

do you know any useful resource for people who wants to use python with Civil3d API ?
The documentation is only available for C# and so on

There is some stuff in the Dynamo Primer at Primer2.DynamoBIM.org. Beyond that C# to Python conversion isn’t too hard for most topics; if you search this forum for the method you are after you should find quite a few samples to work from as well.

1 Like