1

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.

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

1 Answers1

2

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
Callum
  • 578
  • 3
  • 8
  • 1
    This is my first script, it just gets the total length of selected conduit and conduit fittings and runs some calculation in it, i just need to use it continually through the day. Thank you for the great info! – ChuckSpadina Dec 09 '20 at 01:10