There is many a post on the forums already. Search functionality is a fantastic thing.
Public Sub Main()
Dim doc as DrawingDocument
' Is this a drawing document?
Try
doc = ThisApplication.ActiveDocument
Catch
If Not ThisApplication.ActiveDocument.DocumentType = kDrawingDocumentObject Then
MessageBox.Show("This command is only used on drawing documents", _
"Harmony Enterprises Automation", _
MessageBoxButtons.OK, _
MessageBoxIcon.Exclamation)
Exit Sub
End If
End Try
'Set all variables and build paths
iLogicVb.RunExternalRule("SharedVars")
iLogicVb.RunExternalRule("PathBuilder")
' hook the PDF export 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
'If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then 'old
If oPDFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then 'new
oOptions.Value("All_Color_AS_Black") = 0
oOptions.Value("Remove_Line_Weights") = 0
oOptions.Value("Vector_Resolution") = 400
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
End If
'get PDF target folder path
Dim targetFile As String = SharedVariable("fullpdfPath")
If System.IO.File.Exists(targetFile) Then
booleanParam = InputRadioBox("WARNING!", "Overwrite Existing File...", "Cancel Command", False, Title := "Harmony Automation")
If booleanParam = False then Exit Sub
End If
'Set the PDF target file name
oDataMedium.FileName = targetFile
'Save the file
oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
'Was the file created?
Dim argMap As NameValueMap
argMap = ThisApplication.TransientObjects.CreateNameValueMap()
argMap.Add("checkFile", targetFile)
iLogicVb.RunExternalRule("file_Validation",argMap)
End Sub
--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.