【问题标题】:Design Automation API failing to open zip file设计自动化 API 无法打开 zip 文件
【发布时间】:2019-12-02 22:39:20
【问题描述】:

当我在 DA 上运行工作项时,我会收到以下报告:

[07/24/2019 17:50:39] InventorCoreConsole.exe Information: 0 : Loading plug-in: iLogic Plugin
[07/24/2019 17:50:39]     InventorCoreConsole.exe Information: 0 : Activating plug-in: iLogic Plugin
[07/24/2019 17:50:41]     iLogic Plugin: initializing...
[07/24/2019 17:50:43] Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
[07/24/2019 17:50:43] InventorCoreConsole.exe Information: 0 : Opening document: T:\Aces\Jobs\66472a1ecb0f4612a610127e9e0ee497\Jet_Engine_Model.zip
[07/24/2019 17:50:43] 
[07/24/2019 17:50:43] The process 1788 ended.
[07/24/2019 17:50:43] Process exit code: -1
[07/24/2019 17:50:44] 
[07/24/2019 17:50:44] End Inventor Core Engine standard output dump.
[07/24/2019 17:50:44] Error: InventorCoreConsole.exe exits with code -1 which indicates an error.
[07/24/2019 17:50:44] End script phase.
[07/24/2019 17:50:44] Error: An unexpected error happened during phase CoreEngineExecution of job.

通常,打开 zip 文件后会发生错误。我想知道我是否错误地指定了输入,或者服务器是否因为尝试运行 iLogic 插件而崩溃?

以下是活动规格。为输入和输出指定 Zip 文件。

Activity activitySpec = new Activity()

{

Id = activityName,
Appbundles = new List<string>() { string.Format("{0}.{1}+{2}", NickName, appBundleName, Alias) },
CommandLine = new List<string>() { commandLine },
Engine = engineName,
Parameters = new Dictionary<string, Parameter>()
{
    { "inputFile", new Parameter() { Description = "input file", LocalName = "Jet_Engine_Model.zip", Ondemand = false, Required = true, Verb = Verb.Get, Zip = true } },
    { "inputJson", new Parameter() { Description = "input json", LocalName = "params.json", Ondemand = false, Required = false, Verb = Verb.Get, Zip = false } },
    { "outputFile", new Parameter() { Description = "output file", LocalName = "Jet_Engine_Model.zip", Ondemand = false, Required = true, Verb = Verb.Put, Zip = true } }
},
Settings = new Dictionary<string, ISetting>()
{
    { "script", new StringSetting(){ Value = engineAttributes.script } }
}

};

这些是工作项参数。是否有任何应指定的项目缺失?

XrefTreeArgument inputFileArgument = new XrefTreeArgument()
{
Verb = Verb.Get,
Url = string.Format("https://developer.api.autodesk.com/oss/v2/buckets/{0}/objects/{1}", bucketKey, "Jet_Engine_Model.zip"),

Headers = new Dictionary<string, string>(){{ "Authorization", "Bearer " + oauth.access_token }}};

// 2. input json
dynamic inputJson = new JObject();
inputJson.length = lengthParam;
inputJson.numberOfFairings = fairingsParam;
XrefTreeArgument inputJsonArgument = new XrefTreeArgument(){
Verb = Verb.Get,
Url = "data:application/json, " + ((JObject)inputJson).ToString(Formatting.None).Replace("\"", "'")};

// 3. output file
//string outputFileNameOSS = string.Format("{0}_output_{1}", 
DateTime.Now.ToString("yyyyMMddhhmmss"), 
Path.GetFileName(input.inputFile.FileName)); // avoid overriding
XrefTreeArgument outputFileArgument = new XrefTreeArgument(){
Url = string.Format("https://developer.api.autodesk.com/oss/v2/buckets/{0}/objects/{1}", bucketKey, "Jet_Engine_Model.zip"),
Verb = Verb.Put,
Headers = new Dictionary<string, string>(){{"Authorization", "Bearer " + oauth.access_token }}};

【问题讨论】:

    标签: autodesk forge autodesk-designautomation


    【解决方案1】:

    感谢您的命令行。 如果我理解正确,您正在尝试发送您希望在 Inventor 中打开包含的文件之一之前解压缩的压缩文件。在这种情况下,您必须指定包含文件的名称(因为 zip 可以包含多个文件)。您可以通过将属性 PathInZip 添加到 WorkItem 定义中的 inputFile 参数来选择文件的名称。像这样:

    XrefTreeArgument inputFileArgument = new XrefTreeArgument()
    {
        Verb = Verb.Get,
        Url = string.Format("https://developer.api.autodesk.com/oss/v2/buckets/{0}/objects/{1}", bucketKey, "Jet_Engine_Model.zip"),
        Headers = new Dictionary<string, string>(){{ "Authorization", "Bearer " + oauth.access_token }},
        PathInZip = "FileNameInsideZip.ipt"
    };
    

    【讨论】:

    • 使用 PathInZip 参数时,似乎在尝试打开文件路径时添加了两次字符串,并且出现了一个新错误:PathInZip = "Jet_Engine_Model\\Jet Engine Model\\Workspace \_喷气发动机模型.iam", InventorCoreConsole.exe Information: 0 : Opening document: T:\Aces\Jobs\637648f934c24e48b2f1e64d31b34506\Jet_Engine_Model\Jet Engine Model\Workspace\_Jet Engine Model.iam\Jet_Engine_Model\Jet Engine Model\Workspace\_Jet Engine Model.iam [07/24/2019 21:28:24] The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
    • 在命令行参数中,扩展名最初指定为ipt。如果我正在下载 zip 并打开 iam,扩展名应该不同吗?我也许?编辑:看起来它正在解压缩到 PathInZip,然后尝试从解压缩的文件夹中打开 PathInZip,这导致路径冗余。在我的 DA 命令文件中,我指定了要打开的文件,所以我应该能够跳过 PathInZip 参数吗?
    • 尝试打开文件路径时会添加两次字符串。 是的,但这不是问题。我昨天玩了一点 Zip 文件,我认为你的 PathInZip 有误。 PathInZip 为我工作得很好。然后我试图在 PathInZip 值中出错,我得到了你的确切错误。您能否检查一下您的 PathInZip 值是否与实际相符?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-25
    • 1970-01-01
    • 1970-01-01
    • 2012-02-06
    相关资源
    最近更新 更多