Message 1 of 2
error - reload , save and close

Not applicable
07-29-2018
10:46 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I trying to open dwg files in a folder one by one change its xrefs to overlay,reload xrefs and save the dwg and close and the do the same with next one. But I am facing problems in ReloadXrefs and DocumentExtension.CloseAndSave. I am using the following code:
Public Sub processxref() Dim txtbx As String = "D:\sanjay\Autocad\XrefToOverlayDATA\test\" For Each File As FileInfo In New DirectoryInfo(txtbx).GetFiles("*.dwg", SearchOption.AllDirectories) Try Dim ids As ObjectIdCollection = New ObjectIdCollection() Dim doc As Document = DocumentCollectionExtension.Open(Application.DocumentManager, File.FullName, False) Application.DocumentManager.MdiActiveDocument = doc Dim db As Database = doc.Database Dim ed As Editor = doc.Editor Using (doc.LockDocument()) Using tr As Transaction = db.TransactionManager.StartTransaction() Dim dlock As DocumentLock = doc.LockDocument() Dim hs As HostApplicationServices = HostApplicationServices.Current Dim table As BlockTable = CType(tr.GetObject(db.BlockTableId, OpenMode.ForWrite), BlockTable) For Each id As ObjectId In table Try Dim record As BlockTableRecord = CType(tr.GetObject(id, OpenMode.ForRead), BlockTableRecord) If record.IsFromExternalReference Then record.UpgradeOpen() record.IsFromOverlayReference = True record.PathName = "" ids.Add(id) End If Catch ex As Autodesk.AutoCAD.Runtime.Exception Dim tt As String = "" End Try Next tr.Commit() If (ids.Count <> 0) Then db.ReloadXrefs(ids) End If End Using Try DocumentExtension.CloseAndSave(doc, File.Name) Catch ex As System.Exception Dim got As String = ex.ToString End Try End Using Catch ex1 As System.Exception Dim got1 As String = ex1.ToString End Try Next End Sub
Thanks Regards
Sanjay Pandey