[英]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);
}
活动参数...
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文件未生成,因为您的 Activity 调用此函数Run(Document doc)
。 可以在您的日志中看到它,请检查此行:
InventorCoreConsole.exe Information: 0 : Run called with box.ipt
现在只需尝试将您的代码移动到运行(文档文档)功能。
RunWithArguments(Document doc, NameValueMap map)
函数在您的 Activity 的命令行中有任何参数的情况下被调用。 https://forge.autodesk.com/en/docs/design-automation/v3/developers_guide/field-guide/#command-lines
从错误消息看来,您的插件要么没有生成“KeyParameters.txt”文件,要么在错误的位置生成它。 是否有可能您的代码永远不会输入任何 if 语句,或者它在没有创建 txt 文件的情况下最终出现在 catch 语句中? 您可以使用 reportUrl 下载报告,那里可能有更多信息。 您还可以在其中添加更多日志记录以帮助您了解正在发生的事情。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.