简体   繁体   English

在 pyrevit 中运行 python 脚本时是否可以继续在 Revit 中工作?

[英]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.在运行 Revitpythonshell 或使用 XAML gui 运行 python 脚本时,我无法在 Revit 中工作,直到关闭 Revitpythonshell 或 python gui。

Is there a way to keep Revit from becoming inaccessible like this?有没有办法让 Revit 不会像这样无法访问?

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. pyRevit 有一个“非模态”控制台,可让 Revit 保持可访问性。
  • Pythons threading module could be what youre looking for. Pythons threading模块可能是您正在寻找的。 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.当您继续工作时,您可以在后台自动执行许多任务,但有一个重要警告:Revit 是一个单核程序,因此如果您从另一个线程触摸数据库/API - Revit 将崩溃。
  • 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.您的线程将继续运行 - 您只需要使用winforms或其他 UI 工具来让您知道线程在哪里。 I use this to automate non-Database tasks that take 30-45 mins, while continuing to work in Revit.我用它来自动化需要 30-45 分钟的非数据库任务,同时继续在 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.如果您需要继续从脚本访问 Revit 数据库/API,我建议您制作一个简单的 UI 并让它与 Revit 中的ExternalEvent对话。 Here is a fantastic example of using a form with ExternalEvent by Cyril Waechter: pyRevit WPF non-modal trouble这是 Cyril Waechter 使用ExternalEvent表单的一个绝妙示例: pyRevit WPF non-modal trouble

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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