1 Nov 2019

Run command from an AutoCAD AppBundle

There is a sample for running a WorkItem on Design Automation API for AutoCAD (DA4A), but since it's using a shared Activity, it's not clear how DA knows which command to execute.

The tutorial on the learnforge site has all the parts needed, and you can figure out how things work, but I thought I could save you some time ?

First of all we have an AutoCAD add-in which has a command called UpdateParam:

[CommandMethod("UpdateParam", CommandFlags.Modal)]
public static void UpdateParam()
  // ...

This add-in is then used as our AppBundle.

Then inside the Activity we have to do two things (apart from referencing the AppBundle we previously created):

1) In the settings parameter we'll create a script object with value that will contain the actual AutoCAD command script that we want to run on DA
In our case it will simply be calling our UpdateParam command (using \n for line break), i.e. settings.script.value = "UpdateParam\n"

2) Inside the commandLine parameter we can now reference the contents of our script using $(settings[script].path) and pass it after the /s command line switch, i.e. commandLine = "$(engine.path)\\accoreconsole.exe /i $(args[inputFile].path) /al $(appbundles[{0}].path) /s $(settings[script].path)"

FYI, in case of Inventor, instead of passing in a script, we can pass in a full iLogic code, see Run iLogic Rule without AppBundle

Related Article