Message 1 of 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
I am trying to patch together some Ilogic code to delete and replace the title blocks on every sheet in a drawing.
I am stuck at the point that it should go through all the sheets and add the new title block.
Thanks for the help.
SyntaxEditor Code Snippet
Dim oDoc As Inventor.Document oDoc = m_inventorApp ' Find out if TitleBlockDefinition exists Dim bTBDfound As Boolean bTBDfound = False Dim oTBD As TitleBlockDefinition For Each oTBD In oDoc.TitleBlockDefinitions Debug.Print(oTBD.Name) If oTBD.Name = "HMCTITLE" Then bTBDfound = True Exit For End If Next oTBD ' If bTBDfound = False Then' MsgBox("ANSI - Large Title block already deleted")' End' End If oTBD = oDoc.TitleBlockDefinitions("HMCTITLE") If oTBD.IsReferenced = True Then Dim oSheetFormat As SheetFormat, oSheet As Sheet ' Check if there is any instance in SheetFormat/Sheet ' that refers to the TitleBlockDefinition For Each oSheet In oDoc.Sheets If oSheet.TitleBlock.Definition Is oTBD Then ' Delete this instance which refers to the ' TitleBlockDefinition oSheet.TitleBlock.Delete() End If Next For Each oSheetFormat In oDoc.SheetFormats If oSheetFormat.ReferencedTitleBlockDefinition Is oTBD Then ' Delete this instance which refers to the ' TitleBlockDefinition oSheetFormat.Delete() End If Next ' Now you can delete the TitleBlockDefinition. oTBD.Delete() Else ' TitleBlockDefinition is not referenced go ahead and ' delete oTBD.Delete() End If ThisDrawing.ResourceFileName = "z:\templates\HMC DRAWING.idw" ActiveSheet = ThisDrawing.Sheet("Sheet:1") ActiveSheet.TitleBlock = "HMCTITLE" 'ActiveSheet = ThisDrawing.Sheet("Sheet:2") ActiveSheet.TitleBlock = "HMCTITLE" ' 'ActiveSheet = ThisDrawing.Sheet("Sheet:3")'ActiveSheet.TitleBlock = "HMCTITLE" iLogicVb.UpdateWhenDone = True MessageBox.Show("Success", "Iproperty update", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)
Solved! Go to Solution.