简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM