- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello anybody!
I've spent the last two days searching forums and reading through my vba book on exploding block references. I have a drawing my company uses as a base drawing but there's a bunch of layers we don't want on it and the only way to delete the layers is to first explode all the blocks in the drawing.
I wrote some code that deletes the first block it finds, I couldn't get it to loop through and explode all of them. The code below is what I found on these forums and it works but it won't execute the next subroutine because the For statement keeps looping. I need a statement before my IF condition to check the drawing for block references first and if there aren't any it would go to the next sub. I'm almost there! Any help is greatly appreciated, new with VBA.
Sub ExplodeAllBlocks()
Dim oEnt As AcadEntity
For Each oEnt In ThisDrawing.ModelSpace
If TypeOf oEnt Is AcadBlockReference Then
ExpBlock oEnt
End If
Next
End Sub
Sub ExpBlock(ByRef BR)
Dim varEx As Variant
Dim BRef As AcadBlockReference
Dim i As Double
varEx = BR.Explode
BR.Delete
For i = 0 To UBound(varEx)
If TypeOf varEx(i) Is AcadBlockReference Then
Set BRef = varEx(i)
ExpBlock BRef
End If
Next
End Sub
(my next Sub would start here)
Solved! Go to Solution.