When I Insert an Exploded Block I get two copies of the Block

When I Insert an Exploded Block I get two copies of the Block

Anonymous
Not applicable
304 Views
6 Replies
Message 1 of 7

When I Insert an Exploded Block I get two copies of the Block

Anonymous
Not applicable
This is driving me nuts. I use the Following:

ThisDrawing.ActiveLayout.Block.InsertBlock(ptBlkInsPoint, strBlkFileName(x), 1, 1, 1, 0).Explode

But I get TWO copies of the Block, one exploded and one not. What am I doing wrong? I have stepped through the code to watch it work and it seems to work fine, but when I change the text in the exploded portion I see a copy of the unexploded block under it.
0 Likes
305 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable
The Explode method in VBA does not work the same as the Explode command in AutoCAD. In VBA, a copy is created, then each of it's constituents are exploded out leaving the appearance of an exploded block. The solution is to erase the original block reference leaving just the exploded entities.

Joe
--
0 Likes
Message 3 of 7

Anonymous
Not applicable
I have seen that I am not the only one to experience this bug. I cannot think of a single instance since I started on Acad ver. 2.18, where I would want a copy of both the exploded block and the unexploded block on top of each other. I tried the

Set objBlkAttach = ThisDrawing.ModelSpace.InsertBlock(ptBlkInsPoint, strBlkFileName(x), 1, 1, 1, 0)


objBlkAttach.Explode


objBlkAttach.Delete


but with no success, so I'm left with getting a selection set of all the entities and checking for an instance of the block. Thanks for the speedy reply.
0 Likes
Message 4 of 7

Anonymous
Not applicable
Here is an example that should help.

Joe
--
Public Sub ExplodeABlock(BlockName As String)
Dim oBlockRef As AcadBlockReference
Dim IP As Variant
IP = ThisDrawing.Utility.GetPoint(Prompt:="Select insertion point")
Set oBlockRef = ThisDrawing.ModelSpace.InsertBlock(IP, BlockName, 1, 1, 1, 0)
MsgBox "Number of entities: " & ThisDrawing.ModelSpace.Count 'this should be 1
oBlockRef.Explode
oBlockRef.Delete
MsgBox "Number of entities: " & ThisDrawing.ModelSpace.Count 'this should be > 1
End Sub

Public Sub Start()
ExplodeABlock "Block1"
End Sub
0 Likes
Message 5 of 7

Anonymous
Not applicable
How do I insert BLOCK from one drawing to another drawing.
I am using the same code what u people have mentioned here.
But when i run the VB program(NOT VBA)i only see the name of the inserted BLOCK in the new drawing but not the BLOCK phisically.
can any one help!!?
0 Likes
Message 6 of 7

Anonymous
Not applicable
Thanks I got it to work. I was trying to combine the Insert.explode into one command, which does explode it however I then tried to delete it, the problem was that it returned a different name than the block. So I had to take what should work in one command and turn it into three with a Insert, Explode, and then Delete. Your code is right on target. Thanks for the help.
0 Likes
Message 7 of 7

Anonymous
Not applicable
Here is something that should help.

Joe
--
Public Sub CopyObjectsBetweenDocs(CopyToDoc As AcadDocument)
Dim objAcadEntitys() As AcadEntity
Dim objSS As AcadSelectionSet
Dim intI As Integer
Dim objEntity As AcadEntity
Dim objMS As AcadModelSpace
On Error Resume Next
objSS("Test").Delete
Set objSS = Application.ActiveDocument.SelectionSets.Add("Test")
objSS.SelectOnScreen
ReDim objAcadEntitys(objSS.Count - 1)

For Each objEntity In objSS
Set objAcadEntitys(intI) = objEntity
intI = intI + 1
Next objEntity

Set objMS = Application.Documents.Item(CopyToDoc.Name).ModelSpace
Application.ActiveDocument.CopyObjects objAcadEntitys, objMS
objSS.Delete
End Sub

Public Sub Start()
CopyObjectsBetweenDocs Application.Documents.Item(1)
End Sub
0 Likes