How to Automatically Generate PDF from .*IDW or *.DWG: Autodesk Inventor

Check here an iLogic code for Autodesk Inventor that aims to save a copy of your drawing with *.pdf extension

The purpose of the code is to create a *.pdf copy at the time an *.idw or *.dwg file is saved in Inventor.

Working with this code allows the designer:

  • Check changes against the last saved version,
  • access quickly, via adobe Reader, your projects for discussion and demonstration,
  • make sure that, after saving and closing the Program, your *.pdf is a faithful copy of your last modifications.


For install:

  1. Close all Inventor files;
  2. Open your *.idw or *.dwg template, as you use;
  3. Navigate to menu "Manage" and click on "Add Rule";
  4. Enter the name for "Rule";
  5. Copy the code below and paste into "Rule" that you just created;
  6. ' Get the PDF translator Add-In.
    Dim PDFAddIn As TranslatorAddIn
    PDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
    'Set a reference to the active document (the document to be published).
    Dim oDocument As Document
    oDocument = ThisApplication.ActiveDocument
    Dim oContext As TranslationContext
    oContext = ThisApplication.TransientObjects.CreateTranslationContext
    oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
    ' Create a NameValueMap object
    Dim oOptions As NameValueMap
    oOptions = ThisApplication.TransientObjects.CreateNameValueMap
    ' Create a DataMedium object
    Dim oDataMedium As DataMedium
    oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
    
    ' Check whether the translator has 'SaveCopyAs' options
    If PDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then
    'oOptions.Value("All_Color_AS_Black") = 1
    oOptions.Value("Remove_Line_Weights") = 1
    oOptions.Value("Vector_Resolution") = 400
    oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
    'oOptions.Value("Custom_Begin_Sheet") = 2
    'oOptions.Value("Custom_End_Sheet") = 4
    End If
    
    PDFDirectory = ThisDoc.Path
    oFileName = ThisDoc.FileName(False) 'without extension
    
    If ThisDoc.Path =  "" Then
    MessageBox.Show("PDF file not created! Click the button again "Save" to generate the PDF copy", "illogical")
    Return 'exit rule
    Else
    oDataMedium.FileName = PDFDirectory & "\" & oFileName & ".PDF"
    End If
    
    'Publish document.
    PDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
    'Launch the PDF file in whatever application Windows is set to open this document type with
    'i = MessageBox.Show("Preview the PDF file?", "PDF Preview",MessageBoxButtons.YesNo,MessageBoxIcon.Question)
    'If i = vbYes Then ThisDoc.Launch(oDataMedium.FileName)
    
  7. Close the window and Navigate again to the menu "Manage" and click on "Event Triggers";
  8. Select "Before Save Document" and click on "Select Rules..."
  9. Select the rule with the name you just created and close the windows in "OK"
  10. save the file.

From this moment on, the new files created from this template will be creating an automatic copy in *.PDF.

Obs: The copy in *.pdf, will only run from the second time you save the drawing..

 

Good work!


How to Automatically Generate PDF from .*IDW or *.DWG: Autodesk Inventor
scroll to top