Bind drawings

Bind drawings

Anonymous
Not applicable
443 Views
3 Replies
Message 1 of 4

Bind drawings

Anonymous
Not applicable
Im having some trouble binding some drawings. Im pretty sure I have the transaction working correctly but I keep getting an eLockViolation error when I try and bind the drawings - any help super appreciated.

my code:

{code}


Dim ThisDrawing As Document = Application.DocumentManager.MdiActiveDocument
Dim DocDB As Database = ThisDrawing.Database

Dim Trans As Transaction = DocDB.TransactionManager.StartTransaction


'get bt as transaction
Dim DocBT As BlockTable = Trans.GetObject(DocDB.BlockTableId, OpenMode.ForRead)
'enumerat the BTRs
Dim DocBTR As SymbolTableEnumerator
DocBTR = DocBT.GetEnumerator
Dim ObjIDColl As New ObjectIdCollection

While DocBTR.MoveNext = True

Dim record = DocBTR.Current.GetObject(OpenMode.ForRead)

Dim FinRecord As BlockTableRecord = CType(record, BlockTableRecord)
If FinRecord.IsFromExternalReference And FinRecord.IsResolved Then
ObjIDColl.Add(FinRecord.Id)
End If
End While
Trans.Commit()
Trans.Dispose()
DocDB.BindXrefs(ObjIDColl, True)

{code}
0 Likes
444 Views
3 Replies
Replies (3)
Message 2 of 4

arcticad
Advisor
Advisor
try locking the document first

Using lock As DocumentLock = Application.DocumentManager.MdiActiveDocument.LockDocument

... code here.

end using
---------------------------



(defun botsbuildbots() (botsbuildbots))
0 Likes
Message 3 of 4

Anonymous
Not applicable
I actually love you! Why didnt I think of that before?!
0 Likes
Message 4 of 4

arcticad
Advisor
Advisor
I feel so honored.
---------------------------



(defun botsbuildbots() (botsbuildbots))
0 Likes