iLogic - Insert Autocad Block into IDW sheet

iLogic - Insert Autocad Block into IDW sheet

Anonymous
Not applicable
885 Views
4 Replies
Message 1 of 5

iLogic - Insert Autocad Block into IDW sheet

Anonymous
Not applicable

I am looking for some help with using iLogic to insert a Drawing resource of an AutoCAD block onto a sheet in an IDW.  I am able to use iLogic to remove an existing Inventor title block from my sheet.  I then want to insert a saved AutoCAD block of a different title block onto the sheet.  At this point, I have not found the right code to start that process.

 

I am using the AutoCAD Block as when I export this to an AutoCAD DWG file it keep the Attributes linked to AutoCAD fields.  If I convert this to an Actual Inventor title block I lose that function.

 

Thanks,

Mark

0 Likes
886 Views
4 Replies
Replies (4)
Message 2 of 5

chandra.shekar.g
Autodesk Support
Autodesk Support

@Anonymous ,

 

I think, you are looking for insertion of AutoCAD block with attributes into IDW. As it is unable to link attributes through Inventor UI, it seems that it is limitation of Inventor.

 

But it is possible to import AutoBlock with attributes into Inventor DWG file.

 

Sub ImportAutoCADBlockDefinitionsFromFile()
    ' Set a reference to the drawing document.
    ' This assumes an Inventor dwg drawing document is active.
    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument

    ' Create an array of names of the definitions to import
    Dim oDefNames(1) As String
    oDefNames(0) = "DatumFilled45"
    oDefNames(1) = "Borders Default Border"

    ' Import definitions from an external dwg file
    ' Only the specified definitions will be imported. If you want all definitions
    ' to be imported, you can leave the 2nd argument as unspecified.
    Dim oBlockDefs As AutoCADBlockDefinitionsEnumerator
    Set oBlockDefs = oDrawDoc.AutoCADBlockDefinitions.AddFromFile("C:\temp\acad.dwg", oDefNames)
End Sub

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 3 of 5

Anonymous
Not applicable

Thanks,

 

All I want to do is insert the existing AutoCAD block resource onto the sheet of the Inventor DWG. 

 

 

0 Likes
Message 4 of 5

Anonymous
Not applicable

 

 

 

0 Likes
Message 5 of 5

chandra.shekar.g
Autodesk Support
Autodesk Support

@Anonymous,

 

Try below iLogic code to insert AutoBlock from drawing resource.

 

Public Sub Main()
    ' Set a reference to the drawing document.
    ' This assumes a drawing document is active.
    Dim oDrawDoc As DrawingDocument
    oDrawDoc = ThisApplication.ActiveDocument

    ' Obtain a reference to the desired AutoCAD block definition.
    Dim oBlockDef As AutoCADBlockDefinition
    oBlockDef = oDrawDoc.AutoCADBlockDefinitions.Item("24x36 TITLE BLOCK")

    Dim oSheet As Sheet
    oSheet = oDrawDoc.ActiveSheet
	
    ' If the definition contains prompted string inputs...
    Dim sPromptStrings(1) As String
    sPromptStrings(0) = "Mlautenbach"
    sPromptStrings(1) = "1234"

    Dim oTG As TransientGeometry
    oTG = ThisApplication.TransientGeometry

    ' Add an instance of the block definition to the sheet.
    ' Rotate the instance by 45 degrees and scale by .75 when adding.
    ' The symbol will be inserted at (10,10) on the sheet.
    Dim oAutoCADBlock As AutoCADBlock
    oAutoCADBlock = oSheet.AutoCADBlocks.Add(oBlockDef, oTG.CreatePoint2d(0, 0), 0, 1,sPromptStrings)
End Sub

Thanks and regards


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes