# List xrefs loaded in the drawing

**URL:** <https://forum.dynamobim.com/t/list-xrefs-loaded-in-the-drawing/53088>\
**Category:** Civil 3D\
**Created:** [July 17, 2020, 8:16pm UTC](https://forum.dynamobim.com/t/list-xrefs-loaded-in-the-drawing/53088 "2020-07-17T20:16:02Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![keith.sowinski](https://avatars.discourse-cdn.com/v4/letter/k/d26b3c/32.png) [@keith.sowinski](https://forum.dynamobim.com/u/keith.sowinski)\
**Post date:** [July 21, 2020, 12:14pm UTC](https://forum.dynamobim.com/t/list-xrefs-loaded-in-the-drawing/53088/6 "2020-07-21T12:14:39Z")

</div>

Here one way to do it with python.

```
import clr

clr.AddReference('AcMgd')
clr.AddReference('AcDbMgd')

from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.DatabaseServices import *

adoc = Application.DocumentManager.MdiActiveDocument

xrefs = []

with adoc.LockDocument():
	with adoc.Database as db:
		with db.TransactionManager.StartTransaction() as t:
			bt = t.GetObject(db.BlockTableId, OpenMode.ForRead)
			btr = t.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead)

			for oid in btr:
				bl = t.GetObject(oid, OpenMode.ForRead)
				if isinstance(bl, BlockReference):
					if bl.BlockTableRecord.IsFromExternalReference:
						xrefs.append(bl.Name)
						
			
OUT = xrefs
```

---

_[View the full topic](https://forum.dynamobim.com/t/list-xrefs-loaded-in-the-drawing/53088)._
