November 23, 2020

Different ways to run iLogic code

I already talked about running iLogic code that was defined in the Activity - see Run iLogic Rule without AppBundle.

You could also provide the code (inside or the URL to it) in the WorkItem, or keep the file in an AppBundle.

Here are the various ways to do it.

1) Directly in the Activity

Activity:

{
  "commandLine": [
    "$(engine.path)\\InventorCoreConsole.exe /i \"$(args[inputFile].path)\" /s \"$(settings[script].path)\""
  ],
  "parameters": {
    "inputFile": {
      "verb": "get",
      "localName": "inputFile.ipt"
    },
    "outputFile": {
      "verb": "put",
      "localName": "outputFile.ipt"
    }
  },
  "id": "rGm0mO9jVSsD2yBEDk9MRtXQTwsa61y0.RunRule+prod",
  "engine": "Autodesk.Inventor+24",
  "appbundles": [],
  "settings": {
    "script": {
      "value": "Trace.WriteLine(\"Text from iLogicVb file\")"
    }
  },
  "description": "Running iLogic Rule",
  "version": 1
}

2) Directly in the WorkItem

Activity:

{
  "commandLine": [
    "$(engine.path)\\InventorCoreConsole.exe /i \"$(args[inputFile].path)\" /s \"$(args[iLogicVb].path)\""
  ],
  "parameters": {
    "inputFile": {
      "verb": "get",
      "localName": "inputFile.ipt"
    },
    "iLogicVb": {
      "verb": "get",
      "localName": "input.iLogicVb"
    },
    "outputFile": {
      "verb": "put",
      "localName": "outputFile.ipt"
    }
  },
  "id": "rGm0mO9jVSsD2yBEDk9MRtXQTwsa61y0.RunRule+prod",
  "engine": "Autodesk.Inventor+24",
  "appbundles": [],
  "description": "Running iLogic Rule",
  "version": 1
}

WorkItem:

{
  "inputFile": {
    "url": "<url to file>"
  },
  "iLogicVb": {
    "url": "data:application/text,Trace.WriteLine(\"Text from iLogicVb file\")\n"
  },
  "outputFile": {
    "url": "<url to file>"
  }
}

3) Referenced in the WorkItem

Activity: same as in 2)

WorkItem:

{
  "inputFile": {
    "url": "<url to file>"
  },
  "iLogicVb": {
    "url": "<url to iLogicVb file>"
  },
  "outputFile": {
    "url": "<url to file>"
  }
}

4) Stored in the AppBundle

AppBundle:

iLogicVb file in AppBundle

Activity:

{
  "commandLine": [
    "$(engine.path)\\InventorCoreConsole.exe /i \"$(args[inputFile].path)\" /s \"$(appbundles[DaSamplePlugin].path)\\DaSamplePlugin.bundle\\Contents\\input.iLogicVb\""
  ],
  "parameters": {
    "inputFile": {
      "verb": "get",
      "localName": "inputFile.ipt"
    },
    "outputFile": {
      "verb": "put",
      "localName": "outputFile.ipt"
    }
  },
  "id": "rGm0mO9jVSsD2yBEDk9MRtXQTwsa61y0.RunRule+prod",
  "engine": "Autodesk.Inventor+24",
  "appbundles": ["rGm0mO9jVSsD2yBEDk9MRtXQTwsa61y0.DaSamplePlugin+prod"],
  "description": "Running iLogic Rule",
  "version": 1
}

Note: if you load an AppBundle with the /al switch, then the /s switch to load iLogic code will be ignored. You also have to open a document using /i switch along with the /s switch.

Related Posts