Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to insert a block from external drawing to current drawing?

Status
Not open for further replies.

microwave2009

Industrial
Joined
Jul 28, 2009
Messages
1
Location
US
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
 
Hi microwave2009,

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
 
Are the two drawings .dwg or .dxf files?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top