Jump to content

Can you insert an exploded block autocad vba


muck

Recommended Posts

Adding at * in the following code stop the code

ThisDrawing.ModelSpace.InsertBlock startPnt, "*C:\BlockInsert.Dwg", 1#, 1#, 1#, 0

So should adding a star allow this code to work?

Thank you,

Edited by muck
Link to comment
Share on other sites

it looks like I was wrong with the *

 

the best I can find is to explode the block imediately after insertion although the block definition then remains in the drawing

 

Set BlockRefObj = ThisDrawing.ModelSpace.InsertBlock(TriPos, "Tri", CScale, CScale, CScale, 0)
BlockRefObj.Explode

Link to comment
Share on other sites

after you've exploded can't you delete the block from the blocks collection with the

BlockObject.Delete

method?

 

It is also normal after deleting a member from a collection to do a purge method on the drawing database to clean it all up.

 

Deleting a block whose name begins with an * can cause AutoCAD to crash.

Edited by Tyke
Link to comment
Share on other sites

  • 11 months later...

I coded what you wanted, because I also needed that, maybe I'll save somebody time:

   Dim insertionPnt(0 To 2) As Double, BlockRefObj As AcadBlockReference, bname As String, bl As AcadBlock
   bname = "e:\block.dwg"
   insertionPnt(0) = 0: insertionPnt(1) = 0: insertionPnt(2) = 0
   Set BlockRefObj = ThisDrawing.ModelSpace.InsertBlock(insertionPnt, bname, 1#, 1#, 1#, 0)
   BlockRefObj.Explode
   Set bl = GetBlock(BlockRefObj.Name)
   BlockRefObj.Delete
   bl.Delete

Link to comment
Share on other sites

I used this function:

Public Function GetBlock(pavadinimas As String) As AcadBlock
   Dim B1 As AcadBlock
   On Error Resume Next 'Error Free Flow
   Set B1 = ThisDrawing.Blocks.Item(pavadinimas)
   If err.Number <> 0 Then
       Set GetBlock = Nothing
   Else
       Set GetBlock = B1
   End If
   On Error GoTo 0 'Normal Flow
End Function

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...