- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, I have a rule that does to things, first it exports entire .idw to pdf, this works perfectly fine. The second part of the rule searches thru all the sheet names and if it finds one named "BASE PLATE POLE CAP", it activate that drawing sheet, then exports the sheet to it's own pdf so that I have it ready to forward to where we would get them cut.
Our workflow isn't perfect and sometimes I don't have a Job Number or Project number available so I created an If/Then/Else statement to create this second pdf. If the JobNumber custom iProperty exists, create a pdf named "this", if it doesn't exist, the just create a generic pdf name "Base Plate Pole Cap".
I can't get the Base Plate Pole Cap pdf export to function properly, it only exports a pdf named "BASE PLATE POLE CAP", and before that export occurs and the pdf appears in windows explorer, I get the error message box where I have to press OK first. But no one has it open, it isn't even created yet.
Not sure where I have gone wrong with this. Any ideas, thanks!
rule below:
'EXPORT ENTIRE PDF
path_and_namePDF = ThisDoc.PathAndFileName(False)
PDFAddIn = 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 PDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then
oOptions.Value("Remove_Line_Weights") = 1
oOptions.Value("Vector_Resolution") = 4800
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
'oOptions.Value("Custom_Begin_Sheet") = 2
'oOptions.Value("All_Color_AS_Black") = 0
'oOptions.Value("Custom_End_Sheet") = 4
End If
'Set the destination file name
oDataMedium.FileName = path_and_namePDF & ".pdf" 'SET DESTINATION, FILE LOCATION WITH FILE NAME AND EXTENSION
On Error Goto handlePDFLock
Call PDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) ' EXPORT DOCUMENT
'CHECK FOR BASE PLATE POLE CAP SHEET, IF EXIST THEN EXPORT TO PDF
Dim oSheet As Sheet ' Set up an indicator to track progress.
Dim bCheck as Boolean = False
For Each oSheet In ThisApplication.ActiveDocument.Sheets
Dim sSheetName As String = oSheet.Name.Split(":")(0)
If oSheet.Name.StartsWith("BASE PLATE POLE CAP") = True Then
bCheck = True
ActiveSheet = ThisDrawing.Sheet(oSheet.Name)
Exit For
End If
Next
If bCheck = False Then ' Checking we actually found the sheet being looked for.
Return ' No Sheet found with given name so exit.
End If
'if BASE PLATE POLE CAP sheet is found, it should be activated to current sheet, then export current sheet only to pdf
pathPDF = ThisDoc.Path
PDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
oDocument2 = ThisApplication.ActiveDocument
oContext2 = ThisApplication.TransientObjects.CreateTranslationContext
oContext2.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions2 = ThisApplication.TransientObjects.CreateNameValueMap
oDataMedium2 = ThisApplication.TransientObjects.CreateDataMedium
If PDFAddIn.HasSaveCopyAsOptions(oDataMedium2, oContext2, oOptions2) Then
oOptions2.Value("Remove_Line_Weights") = 1
oOptions2.Value("Vector_Resolution") = 4800
oOptions2.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintCurrentSheet
'oOptions.Value("Custom_Begin_Sheet") = 2
'oOptions.Value("All_Color_AS_Black") = 0
'oOptions.Value("Custom_End_Sheet") = 4
End If
'Set the destination file name
If iProperties.Value("Custom", "JobNumber") = False Then
oDataMedium2.FileName = pathPDF & "\" & "BASE PLATE POLE CAP" & ".pdf"
'MessageBox.Show(oDataMedium2.FileName, "Title")
Else
oDataMedium2.FileName = pathPDF & "\" & iProperties.Value("Custom", "JobNumber") & "_BASE PLATE POLE CAP" & ".pdf"
'MessageBox.Show(oDataMedium2.FileName, "Title")
End If
On Error Goto handlePDFLock
'Publish document.
Call PDFAddIn.SaveCopyAs(oDocument2, oContext2, oOptions2, oDataMedium2)
Exit Sub
handlePDFLock:
MessageBox.Show("PDF could not be saved, most likely someone else has it open.", _
"No PDF for you " & ThisApplication.GeneralOptions.UserName & "!")
Resume Next
Product Designer at Teksign Inc.
Inventor 2016 SP1
Dell Precision 3660
i7-12700 @ 2.40GHz-4.90GHz
32GB DDR5 4400MHz RAM
NIVDIA RTX A2000 6GB
Solved! Go to Solution.