Hi @89198826955. Exporting drawings to PDF format has been a very popular topic on this forum for a long time, so a lot of working code examples can be found for that process. The example in this discussion is very basic, so it does not offer any 'options'. If you need to be able to specify options for the export process, then the code will need to become longer and more complex, because it will need to involve accessing and using the TranslatorAddIn that is specifically for exporting PDF's. When doing things that way, more code is required, because the methods involved are asking for more 'inputs', which gives us the chance to customize some options for the export. In the example below, it is also attempting to save the PDF file in the 'next higher' folder than the one the original drawing file is currently within, because that functionality is part of what this discussion is about. It sill also use the same file name as the original file, same as before. But in this example, we are specifying that we want all sheets to be included, the 'all color as black' option is turned off, the 'remove line weights' option is turned off, the 'vector resolution' is set to 720, and the 'launch viewer' option is set to True. So, if it is exporting a multi-sheet drawing, the resulting PDF should have multiple sheets also. Since this code is customized to this forum topic, I have not tested it yet.
Dim oDoc As Inventor.Document = ThisDoc.Document
If oDoc.FileSaveCounter = 0 Then
MsgBox("This Document Must Be Saved First!", vbCritical, "iLogic")
Return
End If
'get the path to the folder this file is directly within
Dim sPath As String = System.IO.Path.GetDirectoryName(oDoc.FullFileName)
'get next higher folder than that previous folder
sPath = System.IO.Path.GetDirectoryName(sPath)
'get this document file's name, without extension, then add PDF extension
Dim sName As String = ThisDoc.FileName(False) & ".pdf"
Dim sNewFullFileName As String = System.IO.Path.Combine(sPath, sName)
'now use TranslatorAddIn for PDF's to export this drawing to a PDF file
Dim oPDFAddIn As Inventor.TranslatorAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
'create variables needed by this tranalstor's methods
Dim oTO As Inventor.TransientObjects = ThisApplication.TransientObjects
Dim oContext As Inventor.TranslationContext = oTO.CreateTranslationContext()
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
Dim oOptions As Inventor.NameValueMap = oTO.CreateNameValueMap()
Dim oDataMedium As Inventor.DataMedium = oTO.CreateDataMedium()
'set the full file name for the new PDF to be created
oDataMedium.FileName = sNewFullFileName
'use initial Translator method to get/set options for export
If oPDFAddIn.HasSaveCopyAsOptions(oDoc, oContext, oOptions) Then
oOptions.Value("Publish_All_Sheets") = 1 ' 0 = False, 1 = True
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
oOptions.Value("All_Color_AS_Black") = 0 ' 0 = False, 1 = True
oOptions.Value("Remove_Line_Weights") = 0 ' 0 = False, 1 = True
oOptions.Value("Vector_Resolution") = 720 '150, 200, 400, 600, 720, 1200, 2400, 4800 ' DPI
oOptions.Value("Launch_Viewer") = 1 ' 0 = False, 1 = True
'call the main method for exporting, supplying all necessary data
Try
oPDFAddIn.SaveCopyAs(oDoc, oContext, oOptions, oDataMedium)
Catch
MsgBox("TranslatorAddIn.SaveCopyAs Method Failed To Export PDF!", vbExclamation, "iLogic")
End Try
End If
If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield

(Not an Autodesk Employee)