无法从 idw 保存 pdf

Failing to save pdf from idw

使用 https://forge.autodesk.com/blog/store-template-documents-appbundle 中的 Adams 示例,我正在尝试打开一个 idw 文档并另存为 pdf。我从 forge

收到以下错误

InventorCoreConsole.exe Information: 0 : Processing failed: System.Runtime.InteropServices.COMException (0x80004005): Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))

at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)

at Inventor.TranslatorAddIn.SaveCopyAs(Object SourceObject, TranslationContext Context, NameValueMap Options, DataMedium TargetData)

at UpdateIPTParam.SampleAutomation.Run(Document doc) InventorCoreConsole.exe Error: 0 : Inventor message: Failed to publish DWF file. InventorCoreConsole.exe Error: 0 : Inventor inner xml:

打开插件的代码

string idwDocPath = System.IO.Path.Combine(assemblyPath, parameters["generator"], "test.idw");
Document idwDoc = m_server.Documents.Open(idwDocPath, false);

pdf输出代码

TranslatorAddIn PDFAddIn;
TranslationContext context;
NameValueMap options;
DataMedium dataMedium;
GetPDFAddIn(m_server, out PDFAddIn, out context, out options, out dataMedium);
dataMedium.FileName = System.IO.Path.Combine(assemblyPath, parameters["generator"], "sampleOutput.pdf");

PDFAddIn.SaveCopyAs(idwDoc, context, options, dataMedium);

// Close the idw
idwDoc.Close(true);

void GetPDFAddIn(InventorServer ThisApplication, out TranslatorAddIn PDFAddIn, out TranslationContext context, out NameValueMap options, out DataMedium dataMedium)
{
    PDFAddIn = (TranslatorAddIn)ThisApplication.ApplicationAddIns.ItemById["{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}"];
    context = ThisApplication.TransientObjects.CreateTranslationContext();
    context.Type = IOMechanismEnum.kFileBrowseIOMechanism;

    options = ThisApplication.TransientObjects.CreateNameValueMap();
    options.Value["All_Color_AS_Black"] = 1;
    options.Value["Remove_Line_Weights"] = 1;
    options.Value["Vector_Resolution"] = 400;
    options.Value["Sheet_Range"] = Inventor.PrintRangeEnum.kPrintAllSheets;
    options.Value["Custom_Begin_Sheet"] = 1;
    options.Value["Custom_End_Sheet"] = 1;

    dataMedium = ThisApplication.TransientObjects.CreateDataMedium();
}

关于我为什么会收到此错误的任何想法?

通常选项设置包含在 if 块中。

// Check whether the translator has 'SaveCopyAs' options
if(PDFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions)){
  // Options for drawings...
  oOptions.Value["Sheet_Range"] = Inventor.PrintRangeEnum.kPrintCurrentSheet;
  oOptions.Value["All_Color_AS_Black"] = 0;
  // oOptions.Value["Remove_Line_Weights"] = 0;
  // oOptions.Value["Vector_Resolution"] = 400;
  // oOptions.Value["Custom_Begin_Sheet"] = 2;
  // oOptions.Value["Custom_End_Sheet"] = 4;
}