Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
i have the following ilopgic code to pull all open drawings and pdf them with the respective rev number after it. The problem is it only put in the rev of the current drawing. say i have 10 drawings all at different revisions. it will label them all the same as the document i run it from. i need it to change which drawing it is looking at and pull the revision from that drawing not the original drawing i ran it from
Sub Main () '-----Inital User Input ----- '-----User defined Scope----- Dim UserChoice = InputRadioBox("What files do you want to export", "Only This Open Document", "All Open Documents", True, Title := "Defined the scope") '-----User question setup ----- Dim UserSelectedActionList = New String(){"PDF & DWG", "PDF Only", "DWG Only"} '-----User question input ----- Dim UserSelectedAction As String = InputListBox("What Format is Required ?", UserSelectedActionList, UserSelectedActionList(0), Title := "File Type to Export", ListName := "File Format Type") If UserChoice = True Then 'UserChoice will be True is first option is selected oDoc = ThisApplication.ActiveEditDocument Call ExportFile(oDoc, UserSelectedAction) '----- Single File Success Message----- Select Case UserSelectedAction Case "PDF & DWG" MessageBox.Show(" File successfully exported to PDF & DWG. ", "Export Complete") Case "PDF Only" MessageBox.Show(" File successfully exported to PDF. ", "Export Complete") Case "DWG Only" MessageBox.Show(" File successfully exported to DWG. ", "Export Complete") End Select Else For Each openDocument As Document In ThisApplication.Documents.VisibleDocuments If openDocument.DocumentType = kDrawingDocumentObject Then Try If Len(openDocument.File.FullFileName) >0 Then Call ExportFile(openDocument, UserSelectedAction) End If Catch End Try End If Next '----- Multi File Success Message ----- Select Case UserSelectedAction Case "PDF & DWG" MessageBox.Show(" All files successfully exported to PDF & DWG. ", "Export Complete") Case "PDF Only" MessageBox.Show(" All files successfully exported to PDF. ", "Export Complete") Case "DWG Only" MessageBox.Show(" All files successfully exported to DWG. ", "Export Complete") End Select End If End Sub Sub ExportFile(ByRef oDocument As Document, UserSelectedOption As String) '-----Check path----- oPath = ThisDoc.Path '-----Get Target folder paths----- oPDFFolder = oPath & "\#Auto PDFs\" oDWGFolder = oPath & "\#Auto DWGs\" '-----Check for the folder paths and create it if they do not exist----- If Not System.IO.Directory.Exists(oPDFFolder) Then System.IO.Directory.CreateDirectory(oPDFFolder) End If If Not System.IO.Directory.Exists(oDWGFolder) Then System.IO.Directory.CreateDirectory(oDWGFolder) End If '----- Fill Variables ----- oFullFileName = oDocument.File.FullFileName oPath = Left(oFullFileName, InStrRev(oFullFileName, "\") -1) oFileName = Right(oFullFileName, Len(oFullFileName) -InStrRev(oFullFileName, "\")) oFilePart = Left(oFileName, InStrRev(oFileName, ".") -1) '-----Load PDF Add In----- 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 '-----PDF options ----- If oPDFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then oOptions.Value("All_Color_AS_Black") = 0 oOptions.Value("Remove_Line_Weights") = 1 oOptions.Value("Vector_Resolution") = 400 oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets End If '----- Sets the appened Revision Number text----- If iProperties.Value(oDoc,"Custom", "09 REVISION") = "" Then 'oRevString = "_(REV MISSING)" ElseIf iProperties.Value(oDoc,"Custom", "09 REVISION") = "AB" Then oRevString = "_" & iProperties.Value(oDoc,"Custom", "09 REVISION") & " (AS BUILT)" Else oRevString = "_rev" & iProperties.Value(oDoc,"Custom", "09 REVISION") & "" End If '-----Set the PDF target file name----- oDataMedium.FileName = oPDFFolder & "\" & oFilePart & oRevString & ".pdf" '-----Export User Selection----- Select Case UserSelectedOption Case "PDF & DWG" 'Export PDF oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) 'Export DWG oDocument.SaveAs(oDWGFolder & "\" & oFilePart & oRevString & ".dwg", True) Case "PDF Only" 'Export PDF oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) Case "DWG Only" 'Export DWG oDocument.SaveAs(oDWGFolder & "\" & oFilePart & oRevString & ".dwg", True) End Select End Sub
Solved! Go to Solution.