09-26-2017
07:14 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
09-26-2017
07:14 AM
1. Added explicit typing to a couple objects (probably not ESSENTIAL).
2. Replaced DataMedium with oDoc in the HasSaveCopyAs options line.
Sub Main()
Dim oDoc As Document
Dim oPDFAddIn As TranslatorAddIn
Dim oContext As TranslationContext
Dim oOptions As NameValueMap
Dim oDataMedium As DataMedium
Try
Dim ThisApp = ThisApplication
Dim TransObj As TransientObjects = ThisApp.TransientObjects
oDoc = ThisDoc.Document
If oDoc.DocumentType <> 12292 Then '12292 = kDrawingDocument object
MessageBox.Show("This Rule must be run from within a Drawing Document.", "Incorrect Document Type")
Exit Sub
End If
oPDFAddIn = ThisApp.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
oContext = TransObj.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = TransObj.CreateNameValueMap
oDataMedium = TransObj.CreateDataMedium
If oPDFAddIn.HasSaveCopyAsOptions(oDoc, oContext, oOptions) Then
oOptions.Value("All_Color_AS_Black") = 0 ' 0 = False, 1 = True
oOptions.Value("Remove_Line_Weights") = 1 ' 0 = False, 1 = True
oOptions.Value("Vector_Resolution") = 400 ' DPI
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
'oOptions.Value("Custom_Begin_Sheet") = 2
'oOptions.Value("Custom_End_Sheet") = 4
End If
'Set the PDF target file name
oDataMedium.FileName = ThisDoc.Path & "\" & ThisDoc.FileName(False) & ".pdf"
Catch
MessageBox.Show("Error Getting Document Information" & vbCr & "Is the current Document Saved?", "Document Error")
End Try
'Publish document
Try
oPDFAddIn.SaveCopyAs(oDoc, oContext, oOptions, oDataMedium)
Catch
MessageBox.Show("Unable to Save PDF" & vbCr & "Is the file open or read only?", "Error Saving Document")
End Try
End Sub
--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.
Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization

iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread
Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects
Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help
Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization
iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread
Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects
Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help
Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type