sdubbs Posted August 5, 2010 Posted August 5, 2010 I have the following code to bind all xref's in a drawing. For some reason, I am getting an "Object was erased" error when the blk.bind is attempted. If I manually bind the xref in AutoCAD it works fine. Private Sub bindXrefs() 'On Error Resume Next 'Bind all xrefs (if g.a.) and save Set Blocks = ThisDrawing.Blocks For Each blk In Blocks 'Detach unloaded xrefs If blk.IsXRef Then If blk.Count < 2 Then 'Detach unloaded xref blk.Detach Else blk.Bind False End If End If Next End Sub Quote
leigh_elkins Posted August 6, 2010 Posted August 6, 2010 The code below was probably one of the first things I did with VBA and hasn't been looked at for a good few years now, but as far as I remember it worked fine. Dim blk As AcadBlock Count = ThisDrawing.Blocks.Count - 1 While Count >= 0 Set blk = ThisDrawing.Blocks.Item(Count) If blk.IsXRef Then On Error Resume Next blk.Bind False On Error Resume Next End If Count = Count - 1 Wend On Error GoTo 0 binderror: Count = Count Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.