1

I'm running a plugin in Design Automation platform on forge however I do run it locally as well for testing. I'd like a way to check if the code is running on forge or not.

Searching I came across this example: https://forge.autodesk.com/blog/how-generate-dynamic-number-output-design-automation-revit-v3

which use if (RuntimeValue.RunOnCloud) however I didn't manage to get it work (nor to find any references for it in forge documentation).

How can I check if I run on forge?

Razyo
  • 39
  • 6
  • Could you give more details on what you are trying to achieve with such a variable (same thing probably can be achieved differently)? Could you also specify what did not work with your approach? – Rahul Bhobe Jul 14 '20 at 15:32
  • For start, which create directory function to use, one working locally one on forge. But I can imagine I'll want to know if I run locally or not for more than just that. I don't have any approach yet, I saw the variable RuntimeValue.RunOnCloud in the link I've attached, but I can't seem to find it or use it. – Razyo Jul 14 '20 at 18:27

2 Answers2

1

Design automation service sets a special environmental variable DAS_WORKITEM_ID for your appbundle code to make use of it should you need. Given that, you should be able to check if this variable is set to determine if your code is running in DA.

    public static string GetWorkitemId()
    {
        return Environment.GetEnvironmentVariable("DAS_WORKITEM_ID");
    }

    public static bool IsRunningInDA()
    {
        return !String.IsNullOrEmpty(GetWorkitemId());
    }

Please note that we recommend using same code for your DA appbundle and Desktop Revit DB addin. Use such tactics with caution and try to minimize the differences between your DB addin and DA appbundle.

Rahul Bhobe
  • 4,165
  • 4
  • 17
  • 32
0

The startup method of your application differs: OnApplicationInitialized versus OnDesignAutomationReadyEvent. You can set a flag in these and check it from you plugin code, cf. e.g., Preparing a Revit Add-in for Design Automation.

Jeremy Tammik
  • 7,333
  • 2
  • 12
  • 17