0
votes

I'm trying to use the Autodesk Forge APIs to automate the placement of a model into an assembly and end up getting a very vague error message:

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

The stack trace suggests to me that one of the parameters passed to Inventor.ComponentOccurrences.Add() is invalid, but I fail to see why that would be. The first parameter is a file path, and I've verified that it contains the path to the downloaded partFile.ipt, and that the file exists in that location. The second parameter is a Matrix which I've really only set a translation of (0, 0) on.

I'm assuming I've misunderstood something, but can't find any relevant documentation that would help me figure out what. Anyways, here's what I've done:

I have three files:

  1. An empty assembly (.iam) file
  2. A model to add to it (.ipt)
  3. An iLogicVb script to place the model at X = 0, Y = 0

At first, I was planning to have the X and Y coordinates be user supplied parameters, but I have no idea if it is even possible to pass parameters to an ilogic rule executed through an activity. So, for now, I'm ignoring that part of the problem and instead hardcoding most of the parameters.

I've created the following design automation entities:

Activity:

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

WorkItem:

{
  "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"
    }
  }
}

Here's the WorkItem execution log:

[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"
}
1

1 Answers

0
votes

I try to reproduce the issue with your iLogic script, activity and workitem configuration with quite simple data, empty assembly file and a part file which only has small cylinder entity.

Actually, it was working fine in my example. So I suspect this is data specific issue, may be ez-entry-10.ipt file.

I recommend you to test the iLogic script and the data set in your local Inventor environment so that you can segregate cause of this error, Design automation environment or data specific issue.