Message 1 of 2
Not applicable
06-29-2021
08:51 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
We have a rule to approve a drawing. After the drawing is approved i would like to make a pdf, but my current rule makes the pdf before the user can fill in the approver. With my cut&paste ilogic knowledge i can't find a solution that works for me. Can somebody help me?
'Approve Drawing
oTime = Now.ToShortDateString
approver = InputBox("Wie is de approver?", "Approve", "MP")
iProperties.Value("Status", "Eng. Approved By") = approver
iProperties.Value("Status", "Eng. Approved Date") = oTime
iProperties.Value("Status", "Design State") = 3
'Check in Drawning
ThisApplication.CommandManager.ControlDefinitions.Item("VaultCheckinTop").Execute2(False)
'Make PDF
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
MsgBox("This Rule '" & iLogicVb.RuleName & "' only works on Drawing Documents.",vbOKOnly, "WRONG DOCUMENT TYPE")
Exit Sub
End If
Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oPDFAddin As TranslatorAddIn
For Each oAddin As ApplicationAddIn In ThisApplication.ApplicationAddIns
If oAddin.DisplayName = "Translator: PDF" Then
oPDFAddin = oAddin
End If
Next
'The following lines are to define needed aspects of the Translator, so we can modify its options.
Dim oTO As TransientObjects = ThisApplication.TransientObjects
Dim oContext As TranslationContext = oTO.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
Dim oOptions As NameValueMap = oTO.CreateNameValueMap
Dim oDataMedium As DataMedium = oTO.CreateDataMedium
'The following If-Then statement defines the Options available, and their Values.
If oPDFAddin.HasSaveCopyAsOptions(oDDoc, oContext, oOptions) Then
oOptions.Value("Publish_All_Sheets") = 1 ' 0 = False, 1 = True
oOptions.Value("Launch_Viewer") = 1 ' 0 = False, 1 = True
oOptions.Value("Publish_Mode") = 62721 'This seems to be the norm for exporting a normal drawing. There may be another value for 3D PDF's.
'oOptions.Value("Enable_Measure") = 1
'oOptions.Value("Enable_Markups") = 1
'oOptions.Value("Output_Path") =
'oOptions.Value("Sheet_Metal_Flat_Pattern") = 0
'oOptions.Value("Sheet_Metal_Part") = 1
'oOptions.Value("Weldment_Symbol") = 0
'oOptions.Value("BOM_Parts_Only") = 1
'oOptions.Value("Instructions") = 0
'oOptions.Value("iAssembly_3D_Models") = 0
'oOptions.Value("iPart_3D_Models") = 0
'oOptions.Value("Publish_Mass_Props") = 1
'oOptions.Value("Publish_Screenshot") = 0
'oOptions.Value("Facet_Quality") = 69379
'oOptions.Value("Facet_Recompute_Tolerance") = 0.001
'oOptions.Value("Sheet_Color") = 0
'oOptions.Value("Custom_Begin_Sheet") = 1
'oOptions.Value("Custom_End_Sheet") = 4 (it is not confirmed that this line works)
oOptions.Value("All_Color_AS_Black") = 0 ' 0 = False, 1 = True
oOptions.Value("Vector_Resolution") = 4800 ' DPI
oOptions.Value("Remove_Line_Weights") = 0 ' 0 = False, 1 = True
'oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
'oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintCurrentSheet
'oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintSheetRange
'oOptions.Value("Print_Excluded_Sheets") = 0 ' 0 = False, 1 = True (DOESN'T SEEM TO BE WORKING YET)
End If
'Set the PDF file name
'oDataMedium.FileName = ThisDoc.Path & "\" & ThisDoc.FileName(False) & ".pdf"
Dim oDeskTopDir As String = System.Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory)
Dim oFileName = IO.Path.GetFileNameWithoutExtension(oDDoc.FullFileName)
oDataMedium.FileName = oDeskTopDir & "\" & oFileName & ".pdf"
'Check to see if the PDF already exists, if it does, ask if you want to over write existing or not.
If System.IO.File.Exists(oDataMedium.FileName) = True Then
oAnswer = MsgBox("A PDF file with this name already exists." & vbCrLf &
"Do you want to over write it with this new one?",vbYesNo + vbQuestion + vbDefaultButton2, "PDF ALREADY EXISTS")
If oAnswer = vbNo Then Return
End If
'Publish PDF
oPDFAddin.SaveCopyAs(oDDoc, oContext, oOptions, oDataMedium)
Solved! Go to Solution.