Insert Title Block and border with iLogic code

Insert Title Block and border with iLogic code

Anonymous
Not applicable
2,772 Views
2 Replies
Message 1 of 3

Insert Title Block and border with iLogic code

Anonymous
Not applicable

Hi All

 

Im only new to Inventor. I have found a iLogic rule to import the title block from a template but it wont import the border I created in the template also. can someone please help

 

here it the rule that is working so far.

 

SyntaxEditor Code Snippet

Sub Main()

If ThisApplication.ActiveDocument Is Nothing Or ThisApplication.ActiveDocumentType <> kDrawingDocumentObject Then
    MsgBox ("Please open a Drawing to work on.")
    Exit Sub

End If

'reference template
ThisDrawing.ResourceFileName = "D:\Inventor\AWE Drawing.idw"
ThisDrawing.KeepExtraResources = False

Dim oDrawingDoc As Inventor.DrawingDocument: oDrawingDoc = ThisApplication.ActiveDocument
Dim SheetNumber As Integer

'Clear out the old Titleblocks & Sheetformats
For SheetNumber = 1 To oDrawingDoc.Sheets.Count
    oDrawingDoc.Sheets(SheetNumber).Activate
    If Not oDrawingDoc.ActiveSheet.TitleBlock Is Nothing Then
        oDrawingDoc.ActiveSheet.TitleBlock.Delete
    End If
Next SheetNumber

'Delete the previous title blocks as the API does not support replacing Sheet Formats.'DeleteSheetFormatsAll (oDrawingDoc)'DeleteBorders (oDrawingDoc)
DeleteTitleBlocks (oDrawingDoc)

Dim resu1t As String="Result"
Dim T1TLE As New ArrayList
T1TLE.Add("AWE Title Block")

resu1t=InputListBox("Select Drawing Title Block", T1TLE, resu1t, _
Title := "Title Block", ListName := "Title Blocks from Template")

    'Set iProperties based On the selection.
    If resu1t="AWE Title Block" Then
    ActiveSheet.TitleBlock = "AWE Title Block"
'    'End If

End If


End Sub

Sub DeleteTitleBlocks(oActiveDoc As Inventor.DrawingDocument)
'Iterate through the collection deleting any titleblocks that are not referenced by the drawing object
Dim oTitle As TitleBlockDefinition
    For Each oTitle In oActiveDoc.TitleBlockDefinitions
        If oTitle.IsReferenced = False Then
        oTitle.Delete
        End If
    Next
End Sub
0 Likes
2,773 Views
2 Replies
Replies (2)
Message 2 of 3

rikard.nilsson
Collaborator
Collaborator

Hi,

 

Maybe I'm not understanding what you try to do but...

 

Here is a simple code for getting titleblock and border from a template (CopyFromDwg.dwg)

Of course you need to activate sheets in order to place them on the sheets..

 

But once you placed the new ones you can finish it up with delete every title and border that not is referenced..

 

 

 

 

 

ThisDrawing.ResourceFileName = "CopyFromDWG.dwg"


ActiveSheet.Border = "TestBorder"  ''Border in my CopyFromDWG.dwg
ActiveSheet.TitleBlock = "TestTitle"  ''Title in my CopyFromDWG.dwg


 For Each oTitle In ThisDrawing.Document.TitleBlockDefinitions
        If oTitle.IsReferenced = False Then
        oTitle.Delete
        End If
 Next
 
 
  For Each oBorder In ThisDrawing.Document.BorderDefinitions
        If oBorder.IsReferenced = False Then
        oBorder.Delete
        End If
 Next 

 

 

Regards

Rikard

0 Likes
Message 3 of 3

danmachen
Advocate
Advocate

Hi there,

 

Just a simple question, why do you want to import the border and title block from a template using iLogic?

 

You can create custom drawing and title blocks within Inventor. i.e. If you want to work with two different templates and two different borders, this is easily done naturally through inventor. New drawings can be created against your template every time a new drawing is opened

 

See my attached image.

Dan Machen
Autodesk Inventor 2019 Certified Professional
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

Ideas that need support:
Circular / Rectangular Point Matrix
Allow Axis & Plane Selection on Rectangular / Circular pattern
Graphical iLogic Programming
0 Likes