Message 1 of 4
Insert AutoCAD block into drawing sheet

Not applicable
04-10-2009
11:20 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
How do we go about inserting an AutoCAD block into a Inventor drawing sheet?
Our Inventor drawing is DWG format. We have tried the code below with both Inventor 2009 and Inventor 2010 with no luck. We did reference the appropriate AutoCAD type library in both cases.
Sub test()
If ThisApplication.ActiveDocument.DocumentType = kDrawingDocumentObject Then
'This is the drawing we want to place the blocks on.
Dim drawingDoc As DrawingDocument
Set drawingDoc = ThisApplication.ActiveDocument
'This is the DWG space of the drawing.
Dim AcadDB As AcadDatabase
Set AcadDB = drawingDoc.ContainingDWGDocument
'This is the block to be added.
Dim pathName As String
pathName = "Filled-2"
'Create the insertion point
Dim insertionPnt(0 To 2) As Double
insertionPnt(0) = 2.92: insertionPnt(1) = 14.829: insertionPnt(2) = 0#
'Insert the block
AcadDB.Layouts(1).Block.InsertBlock insertionPnt, pathName, 1, 1, 1, 0
End If
End Sub
We are using VBA (for now) to figure out the methods/procedure. Once we figure it out, we plan to move this function to VB.NET.
It appears that the block reference is being correctly added to the Paperspace collection in the ContainingDWG object AS IF we had inserted the block manually (via Inventor UI). However, we don't see the insertion on the sheet AND we don't get any errors when running the above code.
Are we missing something here? Is it possible to insert blocks into sheets via the API? Is our only option to read in all the entities of the block to draw sketched symbols via code?
Quick reply is mucho appreciated here... this is for a major project of ours...
Thanks,
George.
Our Inventor drawing is DWG format. We have tried the code below with both Inventor 2009 and Inventor 2010 with no luck. We did reference the appropriate AutoCAD type library in both cases.
Sub test()
If ThisApplication.ActiveDocument.DocumentType = kDrawingDocumentObject Then
'This is the drawing we want to place the blocks on.
Dim drawingDoc As DrawingDocument
Set drawingDoc = ThisApplication.ActiveDocument
'This is the DWG space of the drawing.
Dim AcadDB As AcadDatabase
Set AcadDB = drawingDoc.ContainingDWGDocument
'This is the block to be added.
Dim pathName As String
pathName = "Filled-2"
'Create the insertion point
Dim insertionPnt(0 To 2) As Double
insertionPnt(0) = 2.92: insertionPnt(1) = 14.829: insertionPnt(2) = 0#
'Insert the block
AcadDB.Layouts(1).Block.InsertBlock insertionPnt, pathName, 1, 1, 1, 0
End If
End Sub
We are using VBA (for now) to figure out the methods/procedure. Once we figure it out, we plan to move this function to VB.NET.
It appears that the block reference is being correctly added to the Paperspace collection in the ContainingDWG object AS IF we had inserted the block manually (via Inventor UI). However, we don't see the insertion on the sheet AND we don't get any errors when running the above code.
Are we missing something here? Is it possible to insert blocks into sheets via the API? Is our only option to read in all the entities of the block to draw sketched symbols via code?
Quick reply is mucho appreciated here... this is for a major project of ours...
Thanks,
George.