clr.AddReference('acdbmgdbrep') in Python Script

Hello, everyone! New learner here!

Can anyone explain to me what is clr.AddReference(‘acdbmgdbrep’) made for?

Thanks in advance!

Hi @ricaerrido,

Generally speaking, the first few lines of code are there to add references to external resources that are used in the code. They are always at the top because they are foundational for the rest of the code to function. Think of them like XREFs in a drawing - they are other DWGs that you reference into the current drawing.

When working with applications that have .NET APIs (which many Autodesk programs do, including AutoCAD and Civil 3D), the classes/methods are found in various Dynamic Linked Libraries, or DLLs. For example, if you want to work with AutoCAD MText in your code, then you need to have access to the Autodesk.AutoCAD.DatabaseServices namespace, which is found in the acdbmgd DLL . Another example, say you want to work with Civil 3D Alignments in your code, then you need access to the Autodesk.Civil.DatabaseServices namespace, which is in the AeccDbMgd DLL.

All of those DLLs can be found in the appropriate installation folders, for example:

C:\Program Files\Autodesk\AutoCAD <version>

When adding a new Python node to the Dynamo canvas in Civil 3D, many of the necessary references will already be added for you.


It’s a starting point, but they may not cover everything that you need.

The acdbmgdbrep DLL contains classes in the Autodesk.AutoCAD.BoundaryRepresentation namespace for the boundary representation or ‘brep’ API. This wouldn’t be needed all the time, but one example I can think of is working with meshes.

Here’s a page from the AutoCAD developer’s documentation that may be helpful as well.


What a nice explaination!