Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello Forum,
i have some trouble with my addin function for export Pdf.
public void ExporPDF() { Inventor.Application InvApp = myCad.InvApp; // Get the PDF translator Add-In. Inventor.TranslatorAddIn PDFAddin = InvApp.ApplicationAddIns.ItemById["{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}"] as Inventor.TranslatorAddIn; //Set a reference to the active document (the document to be published). Inventor.DrawingDocument oDocument = InvApp.ActiveDocument as Inventor.DrawingDocument; Inventor.TranslationContext oContext = InvApp.TransientObjects.CreateTranslationContext(); oContext.Type = Inventor.IOMechanismEnum.kFileBrowseIOMechanism; // Create a NameValueMap object Inventor.NameValueMap oOptions = InvApp.TransientObjects.CreateNameValueMap(); // Create a DataMedium object Inventor.DataMedium oDataMedium = InvApp.TransientObjects.CreateDataMedium(); // Check whether the translator has 'SaveCopyAs' options if (PDFAddin.HasSaveCopyAsOptions[oDocument, oContext, oOptions]) { // Options for drawings... oOptions.Value["All_Color_AS_Black"] = 1; oOptions.Value["Remove_Line_Weights"] = 1; oOptions.Value["Vector_Resolution"] = 400; oOptions.Value["Sheet_Range"] = Inventor.PrintRangeEnum.kPrintSheetRange; oOptions.Value["Custom_Begin_Sheet"] = 2; oOptions.Value["Custom_End_Sheet"] = 4; } string filePath = oDocument.FullFileName; filePath = filePath.Substring(0, filePath.Length - 4); // Set the destination file name oDataMedium.FileName = filePath + ".pdf"; // Publish document. PDFAddin.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium);
The Problem with the Lines of Code is, that when i press the Button inside Inventor Addin, an Error that DWF-File cant be published occurs. But the Translater Guid is the correct one for PDF Publishing.
I am wondering because that´s the same function as in the api help documentation. And im realy sure that this works for some weeks perfectly.
Any ideas?
Thats the VBA Code from the API help
Public Sub PublishPDF() ' Get the PDF translator Add-In. Dim PDFAddIn As TranslatorAddIn Set 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 Set oDocument = ThisApplication.ActiveDocument Dim oContext As TranslationContext Set oContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = kFileBrowseIOMechanism ' Create a NameValueMap object Dim oOptions As NameValueMap Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap ' Create a DataMedium object Dim oDataMedium As DataMedium Set oDataMedium = ThisApplication.TransientObjects.CreateDataMedium ' Check whether the translator has 'SaveCopyAs' options If PDFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then ' Options for drawings... oOptions.Value("All_Color_AS_Black") = 0 'oOptions.Value("Remove_Line_Weights") = 0 'oOptions.Value("Vector_Resolution") = 400 'oOptions.Value("Sheet_Range") = kPrintAllSheets 'oOptions.Value("Custom_Begin_Sheet") = 2 'oOptions.Value("Custom_End_Sheet") = 4 End If 'Set the destination file name oDataMedium.FileName = "c:\temp\test.pdf" 'Publish document. Call PDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) End Sub
If my reply was helpful, please give a "Kudo" or click the "Accept as Solution" button below (or both).
Solved! Go to Solution.