【问题标题】:Autodesk Forge Design Automation iLogic errorAutodesk Forge 设计自动化 iLogic 错误
【发布时间】:2021-05-24 17:08:09
【问题描述】:

我正在尝试使用 Autodesk Forge API 自动将模型放置到装配中,但最终收到一条非常模糊的错误消息:

System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

堆栈跟踪向我表明传递给 Inventor.ComponentOccurrences.Add() 的参数之一无效,但我不明白为什么会这样。第一个参数是文件路径,我已经验证它包含下载的 partFile.ipt 的路径,并且该文件存在于该位置。 第二个参数是一个矩阵,我实际上只设置了 (0, 0) 的平移。

我假设我误解了某些内容,但找不到任何相关文档 会帮助我弄清楚什么。无论如何,这就是我所做的:

我有三个文件:

  1. 空程序集 (.iam) 文件
  2. 要添加到其中的模型 (.ipt)
  3. 将模型放置在 X = 0,Y = 0 的 iLogicVb 脚本

起初,我打算将 X 和 Y 坐标作为用户提供的参数, 但我不知道是否甚至可以将参数传递给通过执行的 ilogic 规则 一个活动。所以,就目前而言,我忽略了问题的那一部分,而是对大部分问题进行硬编码 参数。

我创建了以下设计自动化实体:

活动:

{
  commandLine: [
    '$(engine.path)\\InventorCoreConsole.exe /i "$(args[inputFile].path)" /s "$(settings[script].path)"'
  ],
  engine: 'Autodesk.Inventor+24',
  parameters: {
    inputFile: Parameter { verb: 'get', localName: 'inputFile.iam' },
    partFile: Parameter { verb: 'get', localName: 'partFile.ipt' },
    outputFile: Parameter { verb: 'put', localName: 'outputFile.iam' }
  },
  id: '<CLIENT_ID>.add_part',
  appbundles: [],
  settings: {
    script: {
      value: 'oPartPath = String.Concat(ThisDoc.Path, "\\", "partFile.ipt")\n' +
        'addX = 0\n' +
        'addY = 0\n' +
        '\n' +
        'Trace.WriteLine("oPartPath = " & oPartPath)\n' +
        'Trace.WriteLine("addX = " & addX & ", addY = " & addY)\n' +
        '\n' +
        'If (IO.File.Exists(oPartPath)) Then\n' +
        '  Trace.WriteLine("File exists")\n' +
        'Else\n' +
        '  Trace.WriteLine("File does not exist")\n' +
        'End If\n' +
        '\n' +
        'Dim oAsm As AssemblyDocument = ThisDoc.Document\n' +
        'Dim oAsmCompDef As AssemblyComponentDefinition = oAsm.ComponentDefinition\n' +
        'Dim oTG As TransientGeometry = ThisServer.TransientGeometry\n' +
        'Dim oMatrix As Matrix = oTG.CreateMatrix\n' +
        'oMatrix.SetTranslation(oTG.CreateVector( addX / 10, addY / 10 ))\n' +
        '\n' +
        'Trace.WriteLine("oMatrix = " & oMatrix.ToString())\n' +
        '\n' +
        'oOcc = oAsmCompDef.Occurrences.Add(oPartPath, oMatrix )\n' +
        'oOcc.Grounded = True\n'
    }
  },
  version: 1
}

工作项:

{
  "activityId": "redacted.add_part+dev",
  "arguments": {
    "inputFile": {
      "url": "https://developer.api.autodesk.com/oss/v2/buckets/redacted-poc-test-bucket/objects/empty.iam",
      "headers": {
        "Authorization": "Bearer redacted"
      }
    },
    "partFile": {
      "url": "https://developer.api.autodesk.com/oss/v2/buckets/redacted-poc-test-bucket/objects/ez-entry-10.ipt",
      "headers": {
        "Authorization": "Bearer redacted"
      }
    },
    "outputFile": {
      "url": "https://developer.api.autodesk.com/oss/v2/signedresources/redacted?region=US",
      "headers": {
        "Authorization": "Bearer redacted",
        "Content-Type": "application/octet-stream"
      },
      "verb": "put"
    }
  }
}

这是 WorkItem 执行日志:

[02/22/2021 08:12:59] Job information:
"CommandLine":[
  "$(engine.path)\\InventorCoreConsole.exe /i \"$(args[inputFile].path)\" /s \"$(settings[script].path)\""
]
"Settings":{
  "script": {
    "value": "oPartPath = String.Concat(ThisDoc.Path, \"\\\", \"partFile.ipt\")\naddX = 0\naddY = 0\n\nTrace.WriteLine(\"oPartPath = \" & oPartPath)\nTrace.WriteLine(\"addX = \" & addX & \", addY = \" & addY)\n\nIf (IO.File.Exists(oPartPath)) Then\n  Trace.WriteLine(\"File exists\")\nElse\n  Trace.WriteLine(\"File does not exist\")\nEnd If\n\nDim oAsm As AssemblyDocument = ThisDoc.Document\nDim oAsmCompDef As AssemblyComponentDefinition = oAsm.ComponentDefinition\nDim oTG As TransientGeometry = ThisServer.TransientGeometry\nDim oMatrix As Matrix = oTG.CreateMatrix\noMatrix.SetTranslation(oTG.CreateVector( addX / 10, addY / 10 ))\n\nTrace.WriteLine(\"oMatrix = \" & oMatrix.ToString())\n\noOcc = oAsmCompDef.Occurrences.Add(oPartPath, oMatrix )\noOcc.Grounded = True\n"
  },
  "dasreportfaileduploadoptional": {
    "value": "true",
    "isEnvironmentVariable": true
  }
}
"Id":"53a1f62351c3491793eb0cac077e36eb"
"ActivityId":"redacted.add_part+dev"
"Engine.Id":"Autodesk.Inventor!24"
"Apps": [
]
"BoundArguments":{
  "inputFile": {
    "localName": "inputFile.iam",
    "url": "https://developer.api.autodesk.com/redacted",
    "headers": {
      "Authorization": "redacted"
    }
  },
  "partFile": {
    "localName": "partFile.ipt",
    "url": "https://developer.api.autodesk.com/redacted",
    "headers": {
      "Authorization": "redacted"
    }
  },
  "outputFile": {
    "localName": "outputFile.iam",
    "url": "https://developer.api.autodesk.com/redacted",
    "headers": {
      "Authorization": "redacted",
      "Content-Type": "application/octet-stream"
    },
    "verb": "put"
  },
  "onProgress": {
    "ondemand": true,
    "url": "https://wlnr5sjl3a.execute-api.us-east-1.amazonaws.com/redacted",
    "headers": {
      "Content-Type": "application/json",
      "x-das-authorize": "awssigv4(us-east-1)",
      "x-ads-token-data": "{\"access_token\":{\"client_id\":\"redacted\"},\"scope\":\"bucket:create bucket:read bucket:delete data:read data:create data:write\",\"expires_in\":3590,\"client_id\":\"redacted\"}"
    },
    "verb": "put"
  }
}
"Quotas":{
  "limitProcessingTimeSec": 900,
  "limitTotalUncompressedAppsSizeInMB": 500
}
[02/22/2021 08:12:59] Starting work item 53a1f62351c3491793eb0cac077e36eb
[02/22/2021 08:12:59] Start download phase.
[02/22/2021 08:12:59] Start downloading input: verb - 'GET', url - 'https://developer.api.autodesk.com/oss/v2/buckets/redacted-poc-test-bucket/objects/empty.iam'
[02/22/2021 08:12:59] Start downloading input: verb - 'GET', url - 'https://developer.api.autodesk.com/oss/v2/buckets/redacted-poc-test-bucket/objects/ez-entry-10.ipt'
[02/22/2021 08:13:00] '57856' bytes have been written to T:\Aces\Jobs\53a1f62351c3491793eb0cac077e36eb\inputFile.iam.
[02/22/2021 08:13:00] End downloading file 'https://developer.api.autodesk.com/oss/v2/buckets/redacted-poc-test-bucket/objects/empty.iam'.
[02/22/2021 08:13:00] '744448' bytes have been written to T:\Aces\Jobs\53a1f62351c3491793eb0cac077e36eb\partFile.ipt.
[02/22/2021 08:13:00] End downloading file 'https://developer.api.autodesk.com/oss/v2/buckets/redacted-poc-test-bucket/objects/ez-entry-10.ipt'.
[02/22/2021 08:13:00] End download phase successfully.
[02/22/2021 08:13:00] Start preparing script and command line parameters.
[02/22/2021 08:13:00] Command line: [ /i "T:\Aces\Jobs\53a1f62351c3491793eb0cac077e36eb\inputFile.iam" /s "T:\Aces\Jobs\53a1f62351c3491793eb0cac077e36eb\setting_script.scr"]
[02/22/2021 08:13:00] End preparing script and command line parameters.
[02/22/2021 08:13:00] Start script phase.
[02/22/2021 08:13:00] ### Command line arguments: /isolate HKEY_CURRENT_USER\SOFTWARE\AppDataLow\Software\Autodesk\CoreUser\WorkItem_53a1f62351c3491793eb0cac077e36eb "T:\Aces\Jobs\53a1f62351c3491793eb0cac077e36eb\userdata" /exe "T:\Aces\AcesRoot\24.00\coreEngine\Exe\InventorCoreConsole.exe"  /i "T:\Aces\Jobs\53a1f62351c3491793eb0cac077e36eb\inputFile.iam" /s "T:\Aces\Jobs\53a1f62351c3491793eb0cac077e36eb\setting_script.scr".
[02/22/2021 08:13:00] Start Inventor Core Engine standard output dump.
[02/22/2021 08:13:00] InventorCoreConsole.exe Information: 0 : InventorCoreConsole.exe: 25.0.18300.0
[02/22/2021 08:13:00] InventorCoreConsole.exe Information: 0 : Starting Inventor Server.
[02/22/2021 08:13:00] InventorCoreConsole.exe Information: 0 : Started Inventor Server 2020.3 (Build 243373000, 373) (24, 30, 37300, 0000)
[02/22/2021 08:13:00] InventorCoreConsole.exe Information: 0 : Loading plug-in: iLogic Plugin
[02/22/2021 08:13:00]     InventorCoreConsole.exe Information: 0 : Activating plug-in: iLogic Plugin
[02/22/2021 08:13:01]     iLogic Plugin: initializing...
[02/22/2021 08:13:01] InventorCoreConsole.exe Information: 0 : Opening document: T:\Aces\Jobs\53a1f62351c3491793eb0cac077e36eb\inputFile.iam Invisible mode: False
[02/22/2021 08:13:01] InventorCoreConsole.exe Information: 0 : Opened
[02/22/2021 08:13:01] InventorCoreConsole.exe Information: 0 : Loading plug-in: iLogic Plugin
[02/22/2021 08:13:01] InventorCoreConsole.exe Information: 0 : Executing 'RunExternalRule' method on Automation object.
[02/22/2021 08:13:01] oPartPath = T:\Aces\Jobs\53a1f62351c3491793eb0cac077e36eb\partFile.ipt
[02/22/2021 08:13:01] addX = 0, addY = 0
[02/22/2021 08:13:01] File exists
[02/22/2021 08:13:01] oMatrix = System.__ComObject
[02/22/2021 08:13:01] InventorCoreConsole.exe Information: 0 : Performing iLogic diagnostics...
[02/22/2021 08:13:01] InventorCoreConsole.exe Error: 0 : iLogic error 
[02/22/2021 08:13:01]  Context: RuleRunning 
[02/22/2021 08:13:01]  Details: System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
[02/22/2021 08:13:01]    at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
[02/22/2021 08:13:01]    at Inventor.ComponentOccurrences.Add(String FullDocumentName, Matrix Position)
[02/22/2021 08:13:01]    at ThisRule.Main()
[02/22/2021 08:13:01]    at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
[02/22/2021 08:13:01]    at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
[02/22/2021 08:13:01] InventorCoreConsole.exe Information: 0 : End of iLogic diagnostics...
[02/22/2021 08:13:02] Processing failed
[02/22/2021 08:13:03] End Inventor Core Engine standard output dump.
[02/22/2021 08:13:03] Error: Application InventorCoreConsole.exe exits with code -1 which indicates an error.
[02/22/2021 08:13:03] End script phase.
[02/22/2021 08:13:03] Error: An unexpected error happened during phase CoreEngineExecution of job.
[02/22/2021 08:13:03] Job finished with result FailedExecution
[02/22/2021 08:13:03] Job Status:
{
  "status": "failedInstructions",
  "reportUrl": "redacted",
  "stats": {
    "timeQueued": "2021-02-22T08:12:59.6876351Z",
    "timeDownloadStarted": "2021-02-22T08:12:59.8550383Z",
    "timeInstructionsStarted": "2021-02-22T08:13:00.2137491Z",
    "timeInstructionsEnded": "2021-02-22T08:13:03.5494299Z",
    "bytesDownloaded": 802304
  },
  "id": "53a1f62351c3491793eb0cac077e36eb"
}

【问题讨论】:

    标签: autodesk-forge


    【解决方案1】:

    我尝试使用非常简单的数据、空的装配文件和只有小圆柱实体的零件文件来重现您的 iLogic 脚本、活动和工作项配置的问题。

    实际上,在我的示例中它运行良好。所以我怀疑这是特定于数据的问题,可能是 ez-entry-10.ipt 文件。

    我建议您在本地 Inventor 环境中测试 iLogic 脚本和数据集,以便区分导致此错误的原因、设计自动化环境或数据特定问题。

    【讨论】:

    • 就是这样。 ez-entry-10.ipt 文件包含指向父级的未解析链接。非常感谢。
    • 很高兴听到!顺便说一句,如果您不确定如何在设计自动化中将参数传递给 iLogic,您可以在下面的 YouTube 记录中找到方法,从视频 youtube.com/watch?v=kA82e_XcMrY&feature=youtu.be 中的 7:40 开始
    猜你喜欢
    • 2021-01-06
    • 2017-09-08
    • 2018-04-01
    • 2020-04-25
    • 2018-10-08
    • 2017-12-16
    • 1970-01-01
    • 2021-03-13
    • 2017-09-15
    相关资源
    最近更新 更多