Insert AutoCAD block into drawing sheet

Insert AutoCAD block into drawing sheet

Anonymous
Not applicable
994 Views
3 Replies
Message 1 of 4

Insert AutoCAD block into drawing sheet

Anonymous
Not applicable
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.
0 Likes
995 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

Try adding the line drawingDoc.Update to the end of
the code. This should refresh Inventor graphics after changes are made to the
AutoCAD database.

 

Sanjay-


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
face=Arial size=2>
 
0 Likes
Message 3 of 4

Anonymous
Not applicable
Sanjay-

Thank you for your reply. We've tried running "Update" and "Update2" on the drawing document and it hasn't worked for us.

Additional information: If you open the file in AutoCAD, you can see the blocks; however, after saving the file and returning to Inventor the blocks are missing again. We're placing the blocks in paper space.

Any other ideas?

Thanks,
D. Johnson
0 Likes
Message 4 of 4

Anonymous
Not applicable
Final Update: After correspondence with the API team, this functionality is currently unavailable using only Inventor's API. The functionality might be explored in a service pack, but for now you'll have to use a workaround to do this.

After using the originally posted code, save and close the drawing, load and modify (make dirty) the .dwg database using AutoCAD's API, save the .dwg and open it in Inventor.

I haven't tried the workaround myself, but that was the suggestion.

Happy Coding,
D. Johnson
0 Likes