- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
is it possible to edit the attached iLogic in the following way:
- if there is no revision, the pdf has file hasn't extension in file name
- in all other cases, the extension is Rev_"Revision Number"
'iLogic rule to export PDF from Inventor Drawings
'May 5, 2016
Imports System.Windows.Forms
' Query user
'------start of iLogic-------
question = MessageBox.Show("You want to create PDF of this file?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
' Set condition based on answer
If question <> vbYes Then Exit Sub
' Get current location of this file
Dim ExportPath As String = ThisDoc.Path
' Check that this file has been saved and actually exists on disk
If String.IsNullOrEmpty(ExportPath) Then
MsgBox("This file has not yet been saved and doesn't exist on disk! - please save it first",64, "PDF EXPORT!")
Exit Sub
End If
' Define folder browse dialog
Dim Dialog = New FolderBrowserDialog()
' Set options for folder browser dialog
Dialog.SelectedPath = ExportPath
Dialog.ShowNewFolderButton = True
Dialog.Description = "Choose Folder for Export..."
If DialogResult.OK = Dialog.ShowDialog() Then ' Show dialog box
' User clicked 'ok' on dialog box - capture the export path
ExportPath = Dialog.SelectedPath & "\"
Else
Exit Sub ' User clicked 'cancel' on dialog box - exit
End If
Dim SheetRange As String = InputBox("Please enter the range of sheets you want to export." & vbLf & _
"You can use these input types:" & vbLf & " ' 1 ' , ' 1-50 ' ", "Sheet range", "1-50")
If SheetRange = vbNullString Then Exit Sub
Dim SPL As Integer = InStr(SheetRange, "-")
Dim L1 As Integer
Dim L2 As Integer
If SPL > 0 Then
L1 = Val(Left(SheetRange, SPL))
L2 = Val(Mid(SheetRange, SPL + 1))
Else
L1 = Val(SheetRange)
L2 = Val(SheetRange)
End If
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
' Formate PDF Setting
oOptions.Value("All_Color_AS_Black") = 0
oOptions.Value("Remove_Line_Weights") = 1
oOptions.Value("Vector_Resolution") = 150
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintSheetRange
' Range of pages for publishing
oOptions.Value("Custom_Begin_Sheet") = L1
oOptions.Value("Custom_End_Sheet") = L2
ExportPath = ExportPath & "\" & ThisDoc.FileName(False)
If iProperties.Value("Project", "Revision Number") >= "0" Then
ExportPath = ExportPath & "_Rev " & iProperties.Value("Project", "Revision Number")
End If
oDataMedium.FileName = ExportPath & ".pdf"
Try
' Publish document
oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
'--------------------------------------------------?--------------------------------------------------?----------------
' Ask the user if he wants to open the file
question2 = MessageBox.Show("Open PDF file?", "Question",MessageBoxButtons.YesNo,MessageBoxIcon.Question)
If question2 = vbYes Then
ThisDoc.Launch(oDataMedium.FileName)
End If
Catch
MessageBox.Show("PDF not created, most likely someone else has it open.", "No PDF for you " & ThisApplication.GeneralOptions.UserName & "!")
End Try
Solved! Go to Solution.