Connor Ferguson
Connor Ferguson

Reputation: 67

Autodesk Forge Design Automation - Inventor - failedInstructions (FailedMissingOutput)

I am trying to use the WorkItems API to extract key paramaters of a part to a text file. The work item fails with FailedMissingOutput [KeyParameters.txt] which is the file my plugin creates in the working folder. Debugging locally the file is created successfully.

Log: Log

Addin Code is pretty simple:

 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 Params...

    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
                        }
                    }
                };
    }

.....And Work Item arguments (With token and ids removed), the signed resource is a forge bucket resource generated to expire in 60 minutes so that shouldn't be the issue,

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
                        }
                    }
                };
    }

I cannot work out why the KeyParameters.txt file isn't being generated by my addin, but looking at the log it seems it is and maybe the problem is uploading it to the signed resource, my token has all the needed scopes.

Upvotes: 0

Views: 442

Answers (2)

Pavel Holecek
Pavel Holecek

Reputation: 61

The KeyParameters.txt file isn't generated because your Activity calls this function Run(Document doc). It is possible to see it in your log, check this line:

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

Now just try to move your code to the Run(Document doc) function.

The RunWithArguments(Document doc, NameValueMap map) function is called in case that you have any arguments in the command line in your Activity. https://forge.autodesk.com/en/docs/design-automation/v3/developers_guide/field-guide/#command-lines

Upvotes: 2

Jeremy
Jeremy

Reputation: 367

From the error message it seems like your addin is either not generating the "KeyParameters.txt" file or generating it at the wrong location. Is it possible that your code never enter any of the if statement or it end up in the catch statement without creating the txt file? You can download the report using the reportUrl, there might be more information in there. You might also be able to add more logging in there to help you understand what is happening.

Upvotes: 0

Related Questions