Autodesk Forge Design Automation - Inventor - failedInstructions (FailedMissingOutput)

Autodesk Forge Design Automation - Inventor - failedInstructions (FailedMissingOutput)

我正在尝试使用 WorkItems API 将部件的关键参数提取到文本文件中。工作项因 FailedMissingOutput [KeyParameters.txt] 而失败,这是我的插件在工作文件夹中创建的文件。本地调试文件创建成功

日志:

插件代码非常简单:

 public void RunWithArguments(Document doc, NameValueMap map)
    {
        LogTrace("Processing " + doc.FullFileName);
        LogInputData(doc, map);

        try
        {

            var DocDir = System.IO.Path.GetDirectoryName(doc.FullFileName);
            var ParametersOutputFileName = System.IO.Path.Combine(DocDir, "KeyParameters.txt");

            if (doc.DocumentType == DocumentTypeEnum.kPartDocumentObject)
            {
                using (new HeartBeat())
                {
                    // TODO: handle the Inventor part here

                    PartDocument PartDoc = (PartDocument)doc;
                    ExtractKeyParams(PartDoc.ComponentDefinition.Parameters, ParametersOutputFileName);

                }
            }
            else if (doc.DocumentType == DocumentTypeEnum.kAssemblyDocumentObject) // Assembly.
            {
                using (new HeartBeat())
                {
                    // TODO: handle the Inventor assembly here

                    AssemblyDocument AssyDoc = (AssemblyDocument)doc;
                    ExtractKeyParams(AssyDoc.ComponentDefinition.Parameters, ParametersOutputFileName);
                }
            }
        }
        catch (Exception e)
        {
            LogError("Processing failed. " + e.ToString());
        }
    }

    public void ExtractKeyParams(Parameters Params, string OutputFileName)

    {
        List<string> ParamList = new List<string>();
        foreach (Parameter Param in Params)
        {
            if (Param.IsKey)
            {
                ParamList.Add(Param.Name);
            }
        }

        string[] OutputParams = ParamList.ToArray();
        System.IO.File.AppendAllLines(OutputFileName, OutputParams);

    }

Activity 参数...

    private static Dictionary<string, Parameter> GetActivityParams()
    {
        return new Dictionary<string, Parameter>
                {
                    {
                        Constants.Parameters.InventorDoc,
                        new Parameter
                        {
                            Verb = Verb.Get,
                            Description = "File to process"
                        }
                    },
                    {
                        "OutputParams",
                        new Parameter
                        {
                            Verb = Verb.Put,
                            LocalName = "KeyParameters.txt",
                            Description = "Key Parameters Output",
                            Ondemand = false,
                            Required = false
                        }
                    }
                };
    }

.....和工作项参数(删除了令牌和 ID),签名资源是生成的锻造桶资源,将在 60 分钟后过期,所以这不应该是问题,

private static Dictionary<string, IArgument> GetWorkItemArgs()
    {

        Dictionary<string, string> Header = new Dictionary<string, string>();
        Header.Add("Authorization", "Bearer <ACCESS_TOKEN>");

        Dictionary<string, string> Header2 = new Dictionary<string, string>();
        Header2.Add("Authorization", "Bearer <ACCESS_TOKEN>");
         Header2.Add("Content-type", "application/octet-stream");

        return new Dictionary<string, IArgument>
                {
                    {
                        Constants.Parameters.InventorDoc,
                        new XrefTreeArgument
                        {
                            Url = "https://developer.api.autodesk.com/oss/v2/buckets/<BUCKET_KEY>/objects/box.ipt",
                            Headers = Header
                        }
                    },
                    {
                        "OutputParams",
                        new XrefTreeArgument
                        {
                            Verb = Verb.Put,
                            Url = "https://developer.api.autodesk.com/oss/v2/signedresources/<SIGNED_RESOURCE_ID>?region=US",
                            Headers = Header2
                        }
                    }
                };
    }

我无法弄清楚为什么我的插件没有生成 KeyParameters.txt 文件,但查看日志它似乎是,也许问题在于将它上传到签名资源,我的令牌有所有需要的范围。

从错误消息来看,您的插件似乎没有生成 "KeyParameters.txt" 文件或在错误的位置生成它。 您的代码是否有可能永远不会输入任何 if 语句,或者它最终在 catch 语句中而不创建 txt 文件? 您可以使用 reportUrl 下载报告,那里可能有更多信息。您也许还可以在其中添加更多日志记录,以帮助您了解正在发生的事情。

未生成 KeyParameters.txt 文件,因为您的 Activity 调用了此函数 Run(Document doc)。可以在您的日志中看到它,检查这一行:

InventorCoreConsole.exe Information: 0 : Run called with box.ipt

现在尝试将您的代码移动到 运行(Document doc) 函数。

如果您在 Activity 的命令行中有任何参数,则会调用 RunWithArguments(Document doc, NameValueMap map) 函数。 https://forge.autodesk.com/en/docs/design-automation/v3/developers_guide/field-guide/#command-lines