Message 1 of 3
PDF Export - File Naming
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
I'm currently working on an iLogic rule to export all sheets within a .dwg file. I've sourced from other posts on this forum to put together the majority of this code, however the issue I'm having now is that the rule no longer exports all sheets in the .dwg - it only exports the last sheet.
See code below, any help on this would be greatly appreciated, cheers!
Dim oDoc As DrawingDocument oDoc = ThisApplication.ActiveDocument Dim oSheet As Sheet Dim i As Integer = 0 Dim j As Integer = 0 'Creates Array List Dim SheetNamesList As List(Of String) = New List(Of String) For Each oSheet In oDoc.Sheets If i <= 8 Then Dim sString1 As String = Right(oSheet.Name, 2) Dim sString2 As String = Split(oSheet.Name,sString1)(0) SheetNamesList.Add(sString2) End If If i >= 9 Then Dim sString1 As String = Right(oSheet.Name, 3) Dim sString2 As String = Split(oSheet.Name,sString1)(0) SheetNamesList.Add(sString2) End If i = i + 1 Next 'Sort By Sheet Name To Export Dim oString As Object For Each oString In SheetNamesList For Each oSheet In oDoc.Sheets oSheet.ExcludeFromPrinting = True If oSheet.Name.Contains(oString) Then oSheet.ExcludeFromPrinting = False End If Next '['Export PDF 'Save to file location > Exports > PDF folder for any project oPath = ThisDoc.Path ooFolder = oPath & "\Exports\PDF" 'Check for the PDF folder and create it if it does not exist If Not System.IO.Directory.Exists(ooFolder) Then System.IO.Directory.CreateDirectory(ooFolder) End If oFileName = ThisDoc.FileName(False) 'without extension oProject = iProperties.Value("Project", "part number") sSheetRev = oSheet.Revision oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById _ ("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") oDocument = ThisApplication.ActiveDocument oContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism oOptions = ThisApplication.TransientObjects.CreateNameValueMap oDataMedium = ThisApplication.TransientObjects.CreateDataMedium If oPDFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then oOptions.Value("All_Color_AS_Black") = 0 oOptions.Value("Remove_Line_Weights") = 1 oOptions.Value("Vector_Resolution") = 600 oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets End If 'Split Sheet name to find Sheet title only sSplit = Split(oSheet.Name, "-") sSheetName = sSplit(1) sSplit2 = Split(sSheetName, ":") Try : sSheetTitle = sSplit2(0) : Catch : sSheetTitle = oSheet.Title : End Try 'Split Sheet name to find sheet number only sSplit3 = Split(oSheet.Name, "-") sSheetNo = sSplit3(0) sSplit4 = Split(sSheetNo, ":") Try : sSheetNo = sSplit4(0) : Catch : sSheetNo = oSheet.Name : End Try 'Set the PDF target file name oDataMedium.FileName = ooFolder & "\" & oProject & "-" & sSheetNo & "-" & sSheetRev & "-" & sSheetTitle & ".pdf" 'Publish document oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) '] j = j + 1 Next oDoc.Sheets(1).Activate