How to open Dynamo in backgound when start Revit

Hi everyone!!

I use Pyrevit to run dynamo script but in the first time is slow, seem like dynamo run background first.
Can be run Backgound dynamo when I open Revit.

Any software (PyRevit and Revit add-ins included) needs to open and load the various libraries which it utilizes prior to execution. Dynamo is no exception. The delay you are seeing is likely Dynamo attaching those DLLs to the Revit interface. While you might be able to do this at startup (the way other Revit add-ins, including PyRevit do) you’d stuffer a few issues as a result.

  1. You’d shift the occasional delay when calling for a Dynamo functionality when starting PyRevit, to every single time you start Revit, with no exceptions. That isn’t likely worth it.
  2. You’d no longer be operating in the same environment as the larger Dynamo ecosystem, and a result other means of interacting with Dynamo might no longer work.
  3. You’d have to build and maintain this customized version of the software in perpetuity, effectively committing to 1/8 of a year’s worth of work hours to maintenance and testing of your customization.

As a result of items 1, 2, and 3 you’ll spend more time than you’d save by a fair bit. Simplifying your Dynamo environment to reduce the external packages so there are less libraries to load, and reducing Python scripts to only load API classes you need is likely a better investment.

  • another option being to build scripts in pyRevit. They run pretty quickly in that case, but it’s a learning curve to climb towards if your API knowledge is limited.
1 Like

yes I am rebuilding all my dynamo script to python script now :slight_smile: so much to learn, totally two different world.


Cheer!! Thank you!

But I realized delay only the first time I run script from button Pyrevit. In the next time not delay (I think maybe in the first time Dynamo not yet run in background so if when run Revit and Dynamo also run in background maybe solved)

Not sure about PyRevit but you can do so with NonicaTab. You only need to select the option “Execute if open Revit file” and the selected script (or one empty…) would load Dynamo at that time.
Hope this helps.

1 Like

Revit loads the DLLs into the environment at first launch; once they are there they persist until you close Revit. So including Gavin’s recommendation, your options are:

  1. Accept the delay of first execution and move on.
    • Not ideal as we always aim to solve stuff, but if every users has two Revit sessions a day and uses the tool in every Revit session, and it is an added minute to the first run, then you lose 10 minutes a week per user. With build out, testing, and maintenance, how long will it take you to recoup those minutes?
  2. Move the entire code base to and add-in and wait for those libraries to load at execution.
    • This shifts the delay from ‘on demand’ to ‘every time you start Revit.’. All add-ins slow down launch, this is not something which can be mitigated. If it’s an extra minute at startup that might be ok for you though as users expect starting Revit to be slow, and the delay doesn’t break the chain of thought.
  3. Clean up your Dynamo environment so it has less to load at launch.
    • All those custom nodes and UI components slow things down a bit on each launch.
  4. Move the entire code base to PyRevit where you load all libraries on each run.
    • This may be faster if you’re managing what libraries and classes you load in your code (ie: never use from Autodesk.Revit.DB import *) since you’re almost entirely just pulling Revit DLLs it may in fact be orders of magnitude faster. But if/when you get to interaction with outside libraries at scale you will likely start to see a similar delay.
  5. Utilize a service to cause the Dynamo environment to be pre-loaded at Revit launch (similar to what it sounds like is indicating). But again, this moves the delay to every time you start Revit, rather then when you want ot use the tool.