muck Posted September 2, 2010 Share Posted September 2, 2010 Can you insert an exploded block from a dwg file with autocad vba? What would be the code for that in Autocad 2010 vba? Quote Link to comment Share on other sites More sharing options...
dbroada Posted September 2, 2010 Share Posted September 2, 2010 from the cammand line it is -INSERT *BlockName have you tried prefixing your block name with a *? Quote Link to comment Share on other sites More sharing options...
muck Posted September 2, 2010 Author Share Posted September 2, 2010 (edited) 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 September 2, 2010 by muck Quote Link to comment Share on other sites More sharing options...
muck Posted September 2, 2010 Author Share Posted September 2, 2010 Maybe used vba command send to insert the block or maybe try "C:*\BlockInsert.Dwg" in the code. Quote Link to comment Share on other sites More sharing options...
dbroada Posted September 3, 2010 Share Posted September 3, 2010 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 Quote Link to comment Share on other sites More sharing options...
Tyke Posted September 6, 2010 Share Posted September 6, 2010 (edited) 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 September 6, 2010 by Tyke Quote Link to comment Share on other sites More sharing options...
frenkas Posted August 10, 2011 Share Posted August 10, 2011 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 Quote Link to comment Share on other sites More sharing options...
frenkas Posted August 10, 2011 Share Posted August 10, 2011 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 Quote Link to comment Share on other sites More sharing options...
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.