添加绘图文档时出现未指定错误

Unspecified error on adding the Drawing Document

我遇到了一个问题,我需要用指定的模板文件打开一个新的绘图文件,如下所示。

objInventorServer.Documents.Add(Inventor.DocumentTypeEnum.kDrawingDocumentObject, templatePath)

但是这一行在工作项日志中给出了一个未指定的错误。我猜 InventorServer 对象出现了问题。 因为在本地机器中使用与普通 Inventor.Application 对象相同的行,它工作正常。请帮我解决问题。

您需要正确指定 templatePath。这必须是本地完整文件名。无法打开此文件。模板必须是您的输入数据或 appbundle 的一部分。路径如下所示:T:\Aces\Jobsb8d2f73366f47a0a0b90b8c522bd52b\CadData\Templates\Norma.idw

如果绘图文件来自比我 运行ning 的 Inventor Server 更新的版本,我只会 运行 遇到问题,但后来我收到了更多消息:

[05/28/2020 16:23:54]     InventorCoreConsole.exe Information: 0 : 
RunWithArguments called
[05/28/2020 16:23:54]     InventorCoreConsole.exe Information: 0 : Creating 
drawing based on template T:\Aces\Applications7779a582552210117f0484dd24ec3e.rGm0mO9jVSsD2yBEDk9MRtXQTwsa61y0.SampleBundle[9].package\SampleBundlePlugin.bundle\Contents\Templates\ANSI (in).idw
[05/28/2020 16:23:54]     InventorCoreConsole.exe Information: 0 : FileExists = True
[05/28/2020 16:23:54]     InventorCoreConsole.exe Error: 0 : Inventor message: This file was saved in a newer version of the product. Inventor can't open newer versions of drawing (.idw, .dwg) and presentation (.ipn) files.
[05/28/2020 16:23:54] To open a part (.ipt) or an assembly (.iam) file one year newer than your current version, install the latest updates.
[05/28/2020 16:23:54] T:\Aces\Applications7779a582552210117f0484dd24ec3e.rGm0mO9jVSsD2yBEDk9MRtXQTwsa61y0.SampleBundle[9].package\SampleBundlePlugin.bundle\Contents\Templates\ANSI (in).idw (Inventor Server x64 SDK 2020 (Build 240168000, 168))
[05/28/2020 16:23:54] Search in the Inventor help for 'Troubleshooting Opening Newer Files' for information on how to open a newer file.
[05/28/2020 16:23:54]     InventorCoreConsole.exe Error: 0 : Inventor inner xml:
[05/28/2020 16:23:54]     InventorCoreConsole.exe Information: 0 : Deactivating plug-in: SampleBundlePlugin
[05/28/2020 16:23:54]     InventorCoreConsole.exe Information: 0 : : SampleBundlePlugin: deactivating...
[05/28/2020 16:23:54] T h e   p a r a m e t e r   i s   i n c o r r e c t .   ( E x c e p t i o n   f r o m   H R E S U L T :   0 x 8 0 0 7 0 0 5 7   ( E _ I N V A L I D A R G ) )
[05/28/2020 16:23:54]

但那样的话 Open 也会失败

如果我对文件和 Inventor Server 使用相同的版本,则此代码成功:

public void RunWithArguments(Document doc, NameValueMap map)
{
LogTrace("RunWithArguments called");

string idwPath = map.Item["_1"];
LogTrace("Creating drawing based on template " + idwPath);
LogTrace("FileExists = " + System.IO.File.Exists(idwPath).ToString());
Document idwDoc = inventorApplication.Documents.Add(Inventor.DocumentTypeEnum.kDrawingDocumentObject, idwPath); 
LogTrace("Created drawing based on template " + idwPath);
}

这是报告:

[05/28/2020 16:33:33]     InventorCoreConsole.exe Information: 0 : RunWithArguments called
[05/28/2020 16:33:33]     InventorCoreConsole.exe Information: 0 : Creating drawing based on template T:\Aces\Applications\eb17e332f09e0e2951aafbe13df81d70.rGm0mO9jVSsD2yBEDk9MRtXQTwsa61y0.SampleBundle[10].package\SampleBundlePlugin.bundle\Contents\Templates\ANSI (in).idw
[05/28/2020 16:33:33]     InventorCoreConsole.exe Information: 0 : FileExists = True
[05/28/2020 16:33:34]     InventorCoreConsole.exe Information: 0 : Created drawing based on template T:\Aces\Applications\eb17e332f09e0e2951aafbe13df81d70.rGm0mO9jVSsD2yBEDk9MRtXQTwsa61y0.SampleBundle[10].package\SampleBundlePlugin.bundle\Contents\Templates\ANSI (in).idw 

您 运行 是否遇到过所有 Inventor 工程图模板的这个问题?