Message 1 of 9

Not applicable
02-03-2014
07:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have put together some code from some pieces online. It is working well with one exception. It will only replace the 1st and last page titleblocks.
A little background. With our drawings we have a titleblock for page 1 and then we have a titleblock for page 2 and on. The code is replacing the 1st page with the correct (1st) page titleblock and the the last page with the correct (page2) titleblock. The titleblocks in the middle however are getting page 1 titleblocks. Any suggestions would be greatly appreciated. I am very new with iLogic so be gentile:-)
Dim oDrawingDoc As Inventor.DrawingDocument Dim oSheetNumber As Integer Dim oActiveSheetNumber As Integer Dim oActiveSheetName As String Dim oSheet As Sheet Dim oSourceTitleBlockDef As TitleBlockDefinition Dim oNewTitleBlockDef As TitleBlockDefinition oDrawingDoc = ThisApplication.ActiveDocument oActiveSheetName = ActiveSheet.Name oSheet = oDrawingDoc.ActiveSheet If (oSheet.TitleBlock.Name = "page1titleblock") Then oTitleBlockName = "page1titleblock" ElseIf (oSheet.TitleBlock.Name = "page2titleblock") Then oTitleBlockName = "page2titleblock" Else: End If For oSheetNumber = 1 To oDrawingDoc.Sheets.Count oDrawingDoc.Sheets(oSheetNumber).Activate If Not oDrawingDoc.ActiveSheet.TitleBlock Is Nothing Then oDrawingDoc.ActiveSheet.TitleBlock.Delete End If Next oSheetNumber Dim oTitle As TitleBlockDefinition Dim oTitleBlock As TitleBlock For Each oTitle In oDrawingDoc.TitleBlockDefinitions If oTitle.IsReferenced = False Then oTitle.Delete End If Next ThisDrawing.ResourceFileName = "path\to\Template\template.DWG" ThisDrawing.KeepExtraResources = True ActiveSheet.TitleBlock = "page1titleblock" ActiveSheet.TitleBlock = "page2titleblock" oSheetNumber = 1 oDrawingDoc.Sheets(oSheetNumber).Activate ActiveSheet.TitleBlock = oTitleBlockName oSheetNumber = 2 oDrawingDoc.Sheets(oSheetNumber).Activate ActiveSheet.TitleBlock = oTitleBlockName
Solved! Go to Solution.