Message 1 of 16
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
i tried to batch bind xrefs but getting "invalid input error"
could any one please help me please:
Namespace FormVB
Public Class RunApp
<autodesk.autocad.runtime.commandmethod("bxb", autodesk.autocad.runtime.commandflags.session)="">
Public Shared Sub InitForm()
Dim frm As New BatchXrefBind
Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
Dim result As DialogResult = Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(frm)
End Sub
End Class
End Namespace
Public Class BatchXrefBind
Private Sub button_Publish_Click(sender As Object, e As EventArgs) Handles button_Publish.Click
Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
Dim openFile1 As OpenFileDialog = New OpenFileDialog()
openFile1.InitialDirectory = "C\"
openFile1.Filter = "Drawing Files|*.dwg"
openFile1.Multiselect = True
If openFile1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
If openFile1.FileNames.Length > 0 Then
Dim strFile As String
For Each strFile In openFile1.FileNames
Using db As Database = New Database(False, True)
db.ReadDwgFile(strFile, FileOpenMode.OpenForReadAndAllShare, False, Nothing)
Dim bTransMan As DatabaseServices.TransactionManager
Dim bTrans As DatabaseServices.Transaction
Dim bDwg As Document
Dim bBT As BlockTable
Dim bBTR As SymbolTableRecord
Dim bBTE As SymbolTableEnumerator
Dim bBTRr As BlockTableRecord
bDwg = Application.DocumentManager.MdiActiveDocument
bTransMan = bDwg.TransactionManager
bTrans = bTransMan.StartTransaction
Try
bBT = bDwg.Database.BlockTableId.GetObject(OpenMode.ForRead)
bBTE = bBT.GetEnumerator
Dim XrefIds As New ObjectIdCollection
While bBTE.MoveNext = True
bBTR = bBTE.Current.GetObject(OpenMode.ForRead)
bBTRr = CType(bBTR, BlockTableRecord)
If bBTRr.IsFromExternalReference And bBTRr.IsResolved Then
XrefIds.Add(bBTR.Id)
End If
End While
Try
bDwg.Database.BindXrefs(XrefIds, False)
Catch ex As Exception
MsgBox("Error: " & ex.Message)
End Try
bTrans.Commit()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
Finally
bTrans.Dispose()
bTransMan.Dispose()
End Try
db.SaveAs(db.OriginalFileName, True, db.OriginalFileVersion, db.SecurityParameters)
End Using
Next
End If
End If
End Sub
</autodesk.autocad.runtime.commandmethod("bxb",>
Solved! Go to Solution.