Public Sub XrefInsertion(ByVal strPath As String) Dim doc As Document = ApplicationServices.Application.DocumentManager.MdiActiveDocument Dim strFName As String = strPath Dim strBlkName As String = System.IO.Path.GetFileNameWithoutExtension(strPath) Dim ed As Editor = doc.Editor() Dim db As Database = doc.Database Dim trans As Transaction = db.TransactionManager.StartTransaction() Using (trans) Dim myDwg As Document myDwg = ApplicationServices.Application.DocumentManager.MdiActiveDocument Using docloc As DocumentLock = myDwg.LockDocument ' lock current document Try Dim xrefObj As ObjectId = db.OverlayXref(strFName, strBlkName) ' Possibly change OverlayXRef to AttachXRef ' Dim xrefobj2 As ObjectID = db. Dim bt As BlockTable = trans.GetObject(db.BlockTableId, OpenMode.ForRead, False) Dim modelSpace As BlockTableRecord = trans.GetObject(db.CurrentSpaceId, OpenMode.ForWrite) Dim btr As BlockTableRecord = CType(trans.GetObject(xrefObj, OpenMode.ForWrite), BlockTableRecord) Dim br As BlockReference = New BlockReference(New Point3d(0, 0, 0), xrefObj) modelSpace.AppendEntity(br) trans.AddNewlyCreatedDBObject(br, True) trans.Commit() Catch ex As Autodesk.AutoCAD.Runtime.Exception MsgBox(ex.Message & vbLf & ex.StackTrace) End Try End Using End Using End Sub ' Receives full file path then xrefs it into CAD