How to insert a block from external drawing to current drawing?
How to insert a block from external drawing to current drawing?
(OP)
My intention is insert a block "B2" from a external drawing test.dwg to current drawing. The problem is the whole drawing test.dwg was inserted in the current drawing. I know I am confused with "add a reference" and "add a block" but I don't know how to solve it. Seek help. Here is my code:
Sub InsertExternalBlock()
Dim InsertPoint(0 To 2) As Double
Dim insertEXTBlock As AcadExternalReference
Dim PathName As String
'Insert point
InsertPoint(0) = 1: InsertPoint(1) = 1: InsertPoint(2) = 0
'External drawing path which contains the blocks I want to insert
PathName = "C:\test.dwg"
'Add block to the drawing
Set insertEXTBlock = ThisDrawing.ModelSpace.AttachExternalReference(PathName, "B2", InsertPoint, 1, 1, 1, 0, False)
ThisDrawing.Application.ZoomAll
End Sub
Sub InsertExternalBlock()
Dim InsertPoint(0 To 2) As Double
Dim insertEXTBlock As AcadExternalReference
Dim PathName As String
'Insert point
InsertPoint(0) = 1: InsertPoint(1) = 1: InsertPoint(2) = 0
'External drawing path which contains the blocks I want to insert
PathName = "C:\test.dwg"
'Add block to the drawing
Set insertEXTBlock = ThisDrawing.ModelSpace.AttachExternalReference(PathName, "B2", InsertPoint, 1, 1, 1, 0, False)
ThisDrawing.Application.ZoomAll
End Sub





RE: How to insert a block from external drawing to current drawing?
Autodesk doesn't allow this via VB/VBA. You're actually almost home with your approach. You'll need in insert (not AttachExternalReference) the drawing test drawing to get the definition of the block B2 into the drawing, and then insert block B2. The other option is get into your test drawing and wblock B2, and then insert B2 from it's file location.
HTH
Todd
RE: How to insert a block from external drawing to current drawing?