Search code examples
autodesk-forgerevit-apiautodesk-designautomation

How to check if we are on Design Automation cloud or not?


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?


Solution

  • 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.