Search code examples
autodesk-forgerevit-apiautodesk-designautomationautodesk-data-management

Call a method in a bundle on Design Automation


The code to be included in the package and uploaded to DesignAutomation:

private void HandleDesignAutomationReadyEvent(object sender, DesignAutomationReadyEventArgs e)
{
    if (...) // The flag I'm getting from the API side.
    {
        Method1();
    }
    else 
    {
        Method2();
    }

}

The code which I have on the API side:

public async Task RunDesignAutomation()
{
   var workItem = new WorkItem()
   {
      ActivityId = activityName,
      Arguments = new Dictionary<string, IArgument>()
      {
          { "rvtFile",  inputFileArgument },
          { "inputJson",  inputJsonArgument },
          { "result",  outputFileArgument },
          { "onComplete", onCompleteArgument }
      }
   };
  
   _designAutomation.CreateWorkItemAsync(workItem);
}

How can I set my own flag for a WorkItem that will help determine on the bundle side which method to use? (Method1 or Method2)

Note: Method1 and Method2 accept a different 'inputJson'


Solution

  • I'd recommend that you add another argument that you can use to switch between the 2 methods.