I slogged my way through it. Here's some code that seems to work.
Any suggestions would be appreciated.
- Ted
Imports System.IO
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Geometry
Imports DBTransMan = Autodesk.AutoCAD.DatabaseServices.TransactionManager
Public Class clsWdProjGenLT
_
Public Sub UpdateXref()
Dim db As Autodesk.AutoCAD.DatabaseServices.Database
db = New Database(False, False)
db.ReadDwgFile("C:\Swap\DwgBlockText.dwg", IO.FileShare.ReadWrite,
False, Nothing)
Dim tm As DBTransMan = db.TransactionManager
Dim ta As Transaction = tm.StartTransaction()
Dim bt As Autodesk.AutoCAD.DatabaseServices.BlockTable
Dim btr As BlockTableRecord
Dim blockId As ObjectId
Dim iter As IEnumerator
Dim strFname As String
bt = ta.GetObject(db.BlockTableId, OpenMode.ForRead)
iter = bt.GetEnumerator()
Do While iter.MoveNext() ' GetEnumerator(bt)
blockId = iter.Current
btr = ta.GetObject(blockId, OpenMode.ForWrite)
If btr.PathName.Length > 0 Then
'strFname = Path.GetFileName(btr.PathName)
btr.PathName = "c:\swap\x_az.dwg"
Debug.WriteLine(btr.Name & " " & btr.PathName)
End If
Loop
ta.Commit()
ta.Dispose()
db.RetainOriginalThumbnailBitmap = True
'if drawing is open, may throw error on save
db.SaveAs("C:\Swap\DwgBlockText2.dwg", Nothing)
db.Dispose()
End Sub
End Class
"TedSch" wrote in message
news:4881608@discussion.autodesk.com...
Does anyone know how to repath an xref, preferably vb.net?
- Ted Schaefer
WD Partners