iLogic preset options for for PDF export in filedialog

iLogic preset options for for PDF export in filedialog

NickSycamore
Participant Participant
192 Views
5 Replies
Message 1 of 6

iLogic preset options for for PDF export in filedialog

NickSycamore
Participant
Participant

I have an ilogic for exporting pdfs to the correct folder with the correct file name.  Before saving with the PDF translator,  a FileDialog opens so that I can check the file name and set the options.  The issue I am having is, the first time I use the rule after opening inventor, the FileDialog sets the print range to 'Sheet in range: From 5 to 6". After I set it to all sheets it stays but if I close and reopen inventor it goes back to sheets in range.

 

Is there a way to set the FileDialog  options so it defaults to print all sheets before the rule shows the dialog box?

0 Likes
193 Views
5 Replies
Replies (5)
Message 2 of 6

Cris_Davis
Enthusiast
Enthusiast

Try this,

 

PDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
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("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
End If

0 Likes
Message 3 of 6

NickSycamore
Participant
Participant

Thanks for the response Cris.  I added the if statement and it didn't help.  I tried moving it to before the filedialog to see if I could set the options but no luck.

Here is what I have. I works but I don't know how to set the options for the filedialog.  I know I could set the options after the filedialog, before saving the file but I would like to be able to change the options if I want using the filedialog. I just want it to default to print all sheets.

Dim plotPath As String = "C:\"
Dim DefaultFileName As String = "test file.pdf"

Dim PDFAddIn As TranslatorAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")


	Dim oContext As TranslationContext = ThisApplication.TransientObjects.CreateTranslationContext
	oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
	Dim oDataMedium As DataMedium = ThisApplication.TransientObjects.CreateDataMedium
	Dim oOptions As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap
	
	If PDFAddIn.HasSaveCopyAsOptions(odrawdoc, oContext, oOptions) Then
		oOptions.Value("Sheet_Range") = PrintRangeEnum.kPrintAllSheets
	End If
	
	'FILE DIALOG
	Dim oFileDialog As Inventor.FileDialog = Nothing
	ThisApplication.CreateFileDialog(oFileDialog)
	oFileDialog.Filter = "PDF (*.pdf)|*.pdf"
	oFileDialog.InitialDirectory = plotPath
	oFileDialog.FileName = DefaultFileName
	oFileDialog.DialogTitle = "Export PDF"
	oFileDialog.OptionsEnabled = True

	oFileDialog.ShowSave()

	If (String.IsNullOrEmpty(oFileDialog.FileName)) Then
		MsgBox("No name given")
		Exit Sub
	End If
	
	
	'PDF TRANSLATOR

	
	oDataMedium.FileName = oFileDialog.FileName

	PDFAddIn.SaveCopyAs(odrawdoc, oContext, oFileDialog.OptionValues, oDataMedium)

 

0 Likes
Message 4 of 6

jwingateRJECD
Enthusiast
Enthusiast

Try this, I took the file dialogue call that you were using and put it into the pdf export rule I use and was successful in getting the pdf to export all sheets. Hope this helps. 

 

oPath = ThisDoc.Path
oFileName = ThisDoc.FileName(False) 'without extension

oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById _
("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium

oOptions.Value("All_Color_AS_Black") = 0
oOptions.Value("Remove_Line_Weights") = 0
oOptions.Value("Vector_Resolution") = 1200
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets

'get PDF target folder path
oFolder = oPath 

ThisApplication.ActiveView.Update()

'FILE DIALOG
	Dim oFileDialog As Inventor.FileDialog = Nothing
	ThisApplication.CreateFileDialog(oFileDialog)
	oFileDialog.Filter = "PDF (*.pdf)|*.pdf"
	oFileDialog.InitialDirectory = plotPath
	oFileDialog.FileName = DefaultFileName
	oFileDialog.DialogTitle = "Export PDF"
	oFileDialog.OptionsEnabled = True

	oFileDialog.ShowSave()

	If (String.IsNullOrEmpty(oFileDialog.FileName)) Then
		MsgBox("No name given")
		Exit Sub
	End If

'Check for the PDF folder and create it if it does not exist
If Not System.IO.Directory.Exists(oFolder) Then
System.IO.Directory.CreateDirectory(oFolder)
End If

oDataMedium.FileName = oFolder & "\" & oFileName & ".pdf"
oPDFAddIn.SaveCopyAs(ThisApplication.ActiveDocument, oContext, oOptions, oDataMedium)'For PDF's
0 Likes
Message 5 of 6

NickSycamore
Participant
Participant

@jwingateRJECD  This looks like it works because its using the options that are defined by "oOptions" not "oFileDialog.OptionValues".  I would like to have the ability to use the file dialog options so I can print just the current sheet if I have to.  The problem is when I run the rule the default option for sheet range is always set to "Sheets in Range" in the file dialog options.

I found a work around for setting options with the translator.  I can have the options dialog show after the file dialog so I can confirm or change the settings.

 

'change from true to false
oFileDialog
.OptionsEnabled = false

'Then add this after you show the file dialog.
PDFAddIn.ShowSaveCopyAsOptions(odrawdoc,oContext,oOptions)

 

0 Likes
Message 6 of 6

NickSycamore
Participant
Participant

Another thing I just found is that if you use the export pdf in the ribbon or the "AppFileExportPDFCmd" command, Inventor will remember those values as the default options.  I guess Inventor doesn't remember those values when using the translator in iLogic.

0 Likes