ChuckSpadina
ChuckSpadina

Reputation: 15

Is it possible to continue working in Revit while running a python script in pyrevit?

When running Revitpythonshell or running a python script with XAML gui I am unable to work in Revit until closing Revitpythonshell or the python gui.

Is there a way to keep Revit from becoming inaccessible like this?

I would like to keep my script open to continually use while I work.

Upvotes: 1

Views: 692

Answers (1)

Callum
Callum

Reputation: 588

You have a couple of options here depending on what your script is trying to do:

  • pyRevit has a 'non-modal' console that keeps Revit accessible.
  • Pythons threading module could be what youre looking for. You can automate alot of tasks in the background as you continue working, with one big caveat: Revit is a single-core program, so if you touch the database / API from another thread - Revit will crash.
  • You can start a process on a thread, then close the console. Your thread will continue to run - you just have to use winforms or another UI tool to let you know where the thread is up to. I use this to automate non-Database tasks that take 30-45 mins, while continuing to work in Revit.
  • If you need to keep accessing the Revit Database / API from your script, Id recommend making a simple UI and get it talking to an ExternalEvent in Revit. Here is a fantastic example of using a form with ExternalEvent by Cyril Waechter: pyRevit WPF non-modal trouble

Upvotes: 2

Related Questions