Using Pyrevit modules with RevitBatchProcessor

Hello,

I am using RevitBatchProcessor to run some pyrevit scripts I made on multiple models.

Below error occures whenever pyrevit is imported:

Exception: [ValueError] Illegal characters in path.
            - .NET exception: [ArgumentException] Illegal characters in path.

hashlib: 85: [128-128] 'hashlib.py'
urllib2: 39: [93-93] 'urllib2.py'
pyrevit.compat: 140: [25-25] 'C:\Users\Wietse_d\AppData\Roaming\pyRevit\pyRevit\master\pyrevitlib\pyrevit\compat.py'
pyrevit: 96: [25-25] 'C:\Users\Wietse_d\AppData\Roaming\pyRevit\pyRevit\master\pyrevitlib\pyrevit\__init__.py'

To reproduce:

import sys
sys.path += ["C:\Users\XX\AppData\Roaming\pyRevit\pyRevit\master\pyrevitlib",
             "C:\Users\XX\Documents\Github\my-tool\venv\RevitAPI stubs\RVT 23"]
from pyrevit import script

Since RevitBatchProcessor is not actively maintained, I hope someone here can help me out?

If you really need to add a sys path

import sys

sys.path.append(‘C:\Users\XX\AppData\Roaming\pyRevit\pyRevit\master\pyrevitlib’)

But if you run your script with RBP from Revit you should not have to.
Also, no need to import the studs, they are meant as a library for auto complete in your code editor

Hi @baaswietse, that problem is that you’re not escaping the paths correctly.

You have 3 options:

  • escape use double backslashes (\\) to escape them: "C:\\..."
  • use a raw string prepending an r to it: r"C:\.."
  • use forward slashes: "C:/..."

Thank you @Jean-Marc and @sanzoghenzo for your suggestions.
Running below code without the stubs import gives an error.

import sys
sys.path.append('C:\\Users\\XX\\AppData\\Roaming\\pyRevit\\pyRevit\\master\\pyrevitlib')
from pyrevit import script
- ERROR: An error occurred while executing the task script! Operation aborted.|
- Exception: [ImportError] No module named wpf|
- .NET exception: [ImportException] No module named wpf|

When I add the stubs import the same error as before occures.

import sys
sys.path.append('C:\\Users\\XX\\AppData\\Roaming\\pyRevit\\pyRevit\\master\\pyrevitlib')
sys.path.append('C:\\Users\\XX\\Documents\\Github\\WYC-addins\\venv\\RevitAPI stubs\\RVT 23')
from pyrevit import script
- Exception: [ValueError] Illegal characters in path.
- .NET exception: [ArgumentException] Illegal characters in path.

- Further exception information:

hashlib: 85: [128-128] 'hashlib.py'
urllib2: 39: [93-93] 'urllib2.py'
pyrevit.compat: 140: [25-25] 'C:\Users\XX\AppData\Roaming\pyRevit\pyRevit\master\pyrevitlib\pyrevit\compat.py'
pyrevit: 96: [25-25] 'C:\Users\XX\AppData\Roaming\pyRevit\pyRevit\master\pyrevitlib\pyrevit\__init__.py'
<unnamed>: 44: [4-4] 'C:\Users\XX\Documents\test_script.py'

I will repeat:

that said, I am guessing you are running an old version of pyRevit.

and have you tried to read this:

It’s weird because if I don’t import the studs I get this error:

- ERROR: An error occurred while executing the task script! Operation aborted.|
- Exception: [ImportError] No module named wpf|
- .NET exception: [ImportException] No module named wpf|

I am looking for a robust solution to run unattended scheduled tasks on cloud models. Since RBP is able to close popups and dialog boxes, I think it is the bestter solution.

A bunch of (stupid) questions:

  • what pyRevit version do you use? a pyrevit env output would be useful to get the big picture
  • does the script run inside pyrevit (as a .pushbutton)?
  • does pyRevit run at all when starting Revit manually?
  • does the script run with the pyrevit run command?

The thing is that pyrevitlib imports some pyrevit dlls dynamically, and it could be that they’re not detected correctly when using RevitBatchProcessor.
Another cause of pyRevit not loading with revit is that the .addin file was not created correctly (pointing to a non existing/non compiled dll), that’s why I asked those questions.
This is only my guess, I may be totally wrong!

Version 4.8.16:851be7c (master branch)

Yes

Yes

Yes

Is there any way I could test this out?

I changed the path imports to use an r string like this:

import sys
sys.path.append(r'C:\Users\Wietse_d\AppData\Roaming\pyRevit\pyRevit\master\pyrevitlib')
sys.path.append(r'C:\Users\Wietse_d\Documents\Github\WYC-addins\venv\RevitAPI stubs\RVT 23')
from pyrevit import script

Now the error changed, some issue with ironpython.

10:08:15 : 	- ERROR: An error occurred while executing the task script! Operation aborted.
10:08:15 : 	- 
10:08:15 : 	- Exception: [IOError] System.IO.IOException: Could not add reference to assembly IronPython.SQLite
10:08:15 : 	-    at IronPython.Runtime.ClrModule.AddReference(CodeContext context, String name)
10:08:15 : 	-    at IronPython.Runtime.ClrModule.AddReference(CodeContext context, Object[] references)
10:08:15 : 	-    at Microsoft.Scripting.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
10:08:15 : 	-    at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
10:08:15 : 	-    at Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3)
10:08:15 : 	-    at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)
10:08:15 : 	-    at Microsoft.Scripting.Interpreter.FuncCallInstruction`6.Run(InterpretedFrame frame)
10:08:15 : 	-    at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
10:08:15 : 	-    at Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3)
10:08:15 : 	-    at IronPython.Compiler.Ast.CallExpression.Invoke1Instruction.Run(InterpretedFrame frame)
10:08:15 : 	-    at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
10:08:15 : 	-    at Microsoft.Scripting.Interpreter.LightLambda.Run1[T0,TRet](T0 arg0)
10:08:15 : 	-    at IronPython.Compiler.Ast.CallExpression.Invoke0Instruction.Run(InterpretedFrame frame)
10:08:15 : 	-    at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
10:08:15 : 	-    at Microsoft.Scripting.Interpreter.LightLambda.Run1[T0,TRet](T0 arg0)
10:08:15 : 	-    at IronPython.Compiler.RuntimeScriptCode.InvokeTarget(Scope scope)
10:08:15 : 	-    at IronPython.Modules.ResourceMetaPathImporter.load_module(CodeContext context, String fullname)
10:08:15 : 	-    at Microsoft.Scripting.Interpreter.FuncCallInstruction`4.Run(InterpretedFrame frame)
10:08:15 : 	-    at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
10:08:15 : 	-    at Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3)
10:08:15 : 	-    at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)
10:08:15 : 	-    at Microsoft.Scripting.Interpreter.FuncCallInstruction`6.Run(InterpretedFrame frame)
10:08:15 : 	-    at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
10:08:15 : 	-    at Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3)
10:08:15 : 	-    at IronPython.Runtime.PythonContext.Call(CodeContext context, Object func, Object arg0)
10:08:15 : 	-    at IronPython.Runtime.Importer.FindAndLoadModuleFromImporter(CodeContext context, Object importer, String fullName, List path, Object& ret)
10:08:15 : 	-    at IronPython.Runtime.Importer.TryLoadMetaPathModule(CodeContext context, String fullName, List path, Object& ret)
10:08:15 : 	-    at IronPython.Runtime.Importer.ImportTopAbsolute(CodeContext context, String name)
10:08:15 : 	-    at IronPython.Runtime.Importer.ImportModule(CodeContext context, Object globals, String modName, Boolean bottom, Int32 level)
10:08:15 : 	-    at IronPython.Modules.Builtin.__import__(CodeContext context, String name, Object globals, Object locals, Object fromlist, Int32 level)
10:08:15 : 	-    at IronPython.Runtime.Importer.ImportLightThrow(CodeContext context, String fullName, PythonTuple from, Int32 level)
10:08:15 : 	-    at Microsoft.Scripting.Interpreter.FuncCallInstruction`4.Run(InterpretedFrame frame)
10:08:15 : 	-    at Microsoft.Scripting.Interpreter.Interpreter.HandleException(InterpretedFrame frame, Exception exception)
10:08:15 : 	-    at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
10:08:15 : 	-    at Microsoft.Scripting.Interpreter.LightLambda.Run1[T0,TRet](T0 arg0)
10:08:15 : 	-    at IronPython.Compiler.RuntimeScriptCode.InvokeTarget(Scope scope)
10:08:15 : 	-    at IronPython.Runtime.PythonContext.InitializeModule(String fileName, ModuleContext moduleContext, ScriptCode scriptCode, ModuleOptions options)
10:08:15 : 	-    at IronPython.Runtime.Importer.LoadModuleFromSource(CodeContext context, String name, String path)
10:08:15 : 	-    at IronPython.Runtime.Importer.LoadFromDisk(CodeContext context, String name, String fullName, String str)
10:08:16 : 	-    at IronPython.Runtime.Importer.ImportFromPathHook(CodeContext context, String name, String fullName, List path, Func`5 defaultLoader)
10:08:16 : 	-    at IronPython.Runtime.Importer.ImportFromPath(CodeContext context, String name, String fullName, List path)
10:08:16 : 	-    at IronPython.Runtime.Importer.ImportNestedModule(CodeContext context, PythonModule module, String name, List path)
10:08:16 : 	-    at IronPython.Runtime.Importer.ImportModuleFrom(CodeContext context, Object from, String name)
10:08:16 : 	-    at IronPython.Runtime.Importer.ImportModule(CodeContext context, Object globals, String modName, Boolean bottom, Int32 level)
10:08:16 : 	-    at IronPython.Modules.Builtin.__import__(CodeContext context, String name, Object globals, Object locals, Object fromlist, Int32 level)
10:08:16 : 	-    at IronPython.Runtime.Importer.ImportLightThrow(CodeContext context, String fullName, PythonTuple from, Int32 level)
10:08:16 : 	-    at Microsoft.Scripting.Interpreter.FuncCallInstruction`5.Run(InterpretedFrame frame)
10:08:16 : 	-    at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
10:08:16 : 	-    at Microsoft.Scripting.Interpreter.LightLambda.Run1[T0,TRet](T0 arg0)
10:08:16 : 	-    at IronPython.Compiler.RuntimeScriptCode.InvokeTarget(Scope scope)
10:08:16 : 	-    at IronPython.Runtime.PythonContext.InitializeModule(String fileName, ModuleContext moduleContext, ScriptCode scriptCode, ModuleOptions options)
10:08:16 : 	-    at IronPython.Runtime.Importer.LoadModuleFromSource(CodeContext context, String name, String path)
10:08:16 : 	-    at IronPython.Runtime.Importer.LoadFromDisk(CodeContext context, String name, String fullName, String str)
10:08:16 : 	-    at IronPython.Runtime.Importer.ImportFromPathHook(CodeContext context, String name, String fullName, List path, Func`5 defaultLoader)
10:08:16 : 	-    at IronPython.Runtime.Importer.ImportFromPath(CodeContext context, String name, String fullName, List path)
10:08:16 : 	-    at IronPython.Runtime.Importer.ImportTopAbsolute(CodeContext context, String name)
10:08:16 : 	-    at IronPython.Runtime.Importer.ImportModule(CodeContext context, Object globals, String modName, Boolean bottom, Int32 level)
10:08:16 : 	-    at IronPython.Modules.Builtin.__import__(CodeContext context, String name, Object globals, Object locals, Object fromlist, Int32 level)
10:08:16 : 	-    at IronPython.Runtime.Importer.ImportLightThrow(CodeContext context, String fullName, PythonTuple from, Int32 level)
10:08:16 : 	-    at Microsoft.Scripting.Interpreter.FuncCallInstruction`5.Run(InterpretedFrame frame)
10:08:16 : 	-    at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
10:08:16 : 	-    at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
10:08:16 : 	-    at Microsoft.Scripting.Interpreter.ActionCallInstruction`3.Run(InterpretedFrame frame)
10:08:16 : 	-    at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
10:08:16 : 	-    at Microsoft.Scripting.Interpreter.LightLambda.Run5[T0,T1,T2,T3,T4,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
10:08:16 : 	-    at System.Dynamic.UpdateDelegates.UpdateAndExecute4[T0,T1,T2,T3,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3)
10:08:16 : 	-    at IronPython.Compiler.Ast.CallExpression.Invoke2Instruction.Run(InterpretedFrame frame)
10:08:16 : 	-    at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
10:08:17 : 	-    at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
10:08:17 : 	-    at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)
10:08:17 : 	-    at Microsoft.Scripting.Interpreter.DynamicInstruction`4.Run(InterpretedFrame frame)
10:08:17 : 	-    at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
10:08:17 : 	-    at Microsoft.Scripting.Interpreter.LightLambda.Run1[T0,TRet](T0 arg0)
10:08:17 : 	-    at Microsoft.Scripting.Interpreter.FuncCallInstruction`3.Run(InterpretedFrame frame)
10:08:17 : 	-    at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
10:08:17 : 	-    at Microsoft.Scripting.Interpreter.LightLambda.Run3[T0,T1,T2,TRet](T0 arg0, T1 arg1, T2 arg2)
10:08:17 : 	-    at Microsoft.Scripting.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame)
10:08:17 : 	-    at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
10:08:17 : 	- .NET exception: [IOException] Could not add reference to assembly IronPython.SQLite
10:08:17 : 	- 
10:08:17 : 	- Further exception information:
10:08:17 : 	- 
10:08:17 : 	- 	_$164: 63: [28-28] 'sqlite3\__init__.py'
10:08:17 : 	- 	sqlite3: 32: [29-29] 'sqlite3\__init__.py'
10:08:17 : 	- 	pyrevit.framework: 1763: [126-126] 'C:\Users\Wietse_d\AppData\Roaming\pyRevit\pyRevit\master\pyrevitlib\pyrevit\framework.py'
10:08:17 : 	- 	pyrevit: 1008: [96-96] 'C:\Users\Wietse_d\AppData\Roaming\pyRevit\pyRevit\master\pyrevitlib\pyrevit\__init__.py'
10:08:17 : 	- 	<unnamed>: 44: [4-4] 'C:\Users\Wietse_d\Documents\Github\WYC-addins\WYC-addins-v2.extension\lib\BatchProcessor\berekende_parameters.py'
10:08:17 : 	- 	ExecuteScript$111: 57: [82-82] 'C:\Users\Wietse_d\AppData\Local\RevitBatchProcessor\Scripts\script_util.py'
10:08:17 : 	- 	executeTaskScript$108: 155: [214-214] 'C:\Users\Wietse_d\AppData\Local\RevitBatchProcessor\Scripts\revit_script_host.py'
10:08:17 : 	- 	WithErrorHandling$25: 89: [49-49] 'C:\Users\Wietse_d\AppData\Local\RevitBatchProcessor\Scripts\script_host_error.py'
10:08:17 : 	- 	processDocument$106: 76: [224-229] 'C:\Users\Wietse_d\AppData\Local\RevitBatchProcessor\Scripts\revit_script_host.py'
10:08:17 : 	- 	WithOpenedCloudDocument$96: 254: [284-284] 'C:\Users\Wietse_d\AppData\Local\RevitBatchProcessor\Scripts\revit_script_util.py'
10:08:17 : 	- 	revitAction$94: 55: [340-349] 'C:\Users\Wietse_d\AppData\Local\RevitBatchProcessor\Scripts\revit_script_util.py'
10:08:17 : 	- 	WithDocumentOpeningErrorReporting$93: 61: [370-370] 'C:\Users\Wietse_d\AppData\Local\RevitBatchProcessor\Scripts\revit_script_util.py'
10:08:17 : 	- 	action$92: 37: [363-363] 'C:\Users\Wietse_d\AppData\Local\RevitBatchProcessor\Scripts\revit_script_util.py'
10:08:17 : 	- 	WithDialogBoxShowingHandler$91: 103: [88-88] 'C:\Users\Wietse_d\AppData\Local\RevitBatchProcessor\Scripts\revit_dialog_util.py'
10:08:17 : 	- 	action$90: 38: [384-384] 'C:\Users\Wietse_d\AppData\Local\RevitBatchProcessor\Scripts\revit_script_util.py'
10:08:17 : 	- 	WithFailuresProcessingHandler$88: 118: [176-176] 'C:\Users\Wietse_d\AppData\Local\RevitBatchProcessor\Scripts\revit_failure_handling.py'
10:08:17 : 	- 	action$87: 49: [386-386] 'C:\Users\Wietse_d\AppData\Local\RevitBatchProcessor\Scripts\revit_script_util.py'
10:08:17 : 	- 	WithExceptionLogging$86: 66: [165-165] 'C:\Users\Wietse_d\AppData\Local\RevitBatchProcessor\Scripts\revit_script_util.py'
10:08:18 : 	- 	WithAutomatedErrorHandling$85: 66: [388-388] 'C:\Users\Wietse_d\AppData\Local\RevitBatchProcessor\Scripts\revit_script_util.py'
10:08:18 : 	- 	WithErrorReportingAndHandling$84: 66: [365-365] 'C:\Users\Wietse_d\AppData\Local\RevitBatchProcessor\Scripts\revit_script_util.py'
10:08:18 : 	- 	RunCloudDocumentAction$83: 114: [351-351] 'C:\Users\Wietse_d\AppData\Local\RevitBatchProcessor\Scripts\revit_script_util.py'
10:08:18 : 	- 	RunBatchTaskScript$63: 1349: [238-247] 'C:\Users\Wietse_d\AppData\Local\RevitBatchProcessor\Scripts\revit_script_host.py'
10:08:18 : 	- 	<lambda$3>$62: 30: [384-384] 'C:\Users\Wietse_d\AppData\Local\RevitBatchProcessor\Scripts\revit_script_host.py'
10:08:18 : 	- 	WithErrorHandling$25: 89: [49-49] 'C:\Users\Wietse_d\AppData\Local\RevitBatchProcessor\Scripts\script_host_error.py'
10:08:18 : 	- 	DoRevitSessionProcessing$46: 316: [383-388] 'C:\Users\Wietse_d\AppData\Local\RevitBatchProcessor\Scripts\revit_script_host.py'
10:08:18 : 	- 	<lambda$4>$45: 36: [419-425] 'C:\Users\Wietse_d\AppData\Local\RevitBatchProcessor\Scripts\revit_script_host.py'
10:08:18 : 	- 	WithErrorHandling$25: 89: [49-49] 'C:\Users\Wietse_d\AppData\Local\RevitBatchProcessor\Scripts\script_host_error.py'
10:08:18 : 	- 	outputStreamWriterAction$42: 66: [418-429] 'C:\Users\Wietse_d\AppData\Local\RevitBatchProcessor\Scripts\revit_script_host.py'
10:08:18 : 	- 	UsingStream$39: 61: [84-84] 'C:\Users\Wietse_d\AppData\Local\RevitBatchProcessor\Scripts\stream_io_util.py'
10:08:18 : 	- 	outputStreamAction$40: 73: [432-432] 'C:\Users\Wietse_d\AppData\Local\RevitBatchProcessor\Scripts\revit_script_host.py'
10:08:18 : 	- 	UsingStream$39: 61: [84-84] 'C:\Users\Wietse_d\AppData\Local\RevitBatchProcessor\Scripts\stream_io_util.py'
10:08:18 : 	- 	Main$26: 205: [435-435] 'C:\Users\Wietse_d\AppData\Local\RevitBatchProcessor\Scripts\revit_script_host.py'
10:08:18 : 	- 	WithErrorHandling$25: 89: [49-49] 'C:\Users\Wietse_d\AppData\Local\RevitBatchProcessor\Scripts\script_host_error.py'
10:08:18 : 	- 	<unnamed>: 451: [447-451] 'C:\Users\Wietse_d\AppData\Local\RevitBatchProcessor\Scripts\revit_script_host.py'
10:08:18 : 	- 
10:08:18 : 	- Closed cloud model.
10:08:18 : 	- 
10:08:18 : 	- Operation completed.

Can I say it again?.. remove the stubs imports line, it has nothing to do with the execution of your script. Promise, it is the last time I mention it (if you remove it :rofl:)

I even asked ChatGPT to explain it for me ;p

In Python, “stubs” or “stub files” typically refer to files with the .pyi extension. These files are used to provide type hints for Python code, especially for libraries and modules where the source code is not available or when you want to add type hints to existing code without modifying it. Stub files help in static type checking, allowing tools like MyPy to verify that the code adheres to specified types.

Here are some common use cases for stubs:

  1. Type Checking: Stubs provide type information for third-party libraries or dynamically typed Python code, helping tools like MyPy perform static type checking.

  2. Documentation: Stubs can serve as a form of documentation, providing clear information about the expected types of function arguments, return values, and variables.

  3. IDE Support: Integrated Development Environments (IDEs) like PyCharm and VSCode can use stub files to provide better code completion, linting, and error checking.

Structure of a Stub File

A stub file typically contains the same structure as the corresponding Python file but with type annotations and without the actual implementation. For example:

# foo.py
def add(a, b):
    return a + b

# foo.pyi
def add(a: int, b: int) -> int: ...

In the stub file (foo.pyi), the function add is annotated with the types of its parameters and return value, but the function body is replaced with an ellipsis (...).

Creating Stub Files

To create stub files for a module or package:

  1. Create a .pyi File: For a single module, create a file with the same name but with the .pyi extension.
  2. Package Stubs: For a package, create a directory with the package name and include __init__.pyi for the package itself and individual .pyi files for each module in the package.

Example Directory Structure

For a package mypackage:

mypackage/
    __init__.py
    module1.py
    module2.py

mypackage-stubs/
    __init__.pyi
    module1.pyi
    module2.pyi

Using Stub Files

To use stub files, ensure they are placed in the same directory as the Python modules or specify the location using a py.typed marker file.

Tools for Generating Stub Files

  • mypy: MyPy can generate stub files using the stubgen tool.
  • pyright: A static type checker and language server for TypeScript and Python, can also help in generating and validating stubs.

Conclusion

Stub files are a powerful tool for adding type annotations to Python code, improving code quality, documentation, and developer experience. They are especially useful in large codebases and when working with third-party libraries that lack type hints.

import sys
sys.path.append(r'C:\Users\XX\AppData\Roaming\pyRevit\pyRevit\master\pyrevitlib')
from pyrevit import script

Removing the stubs import line throws below error.
wpf.py is a file located in the stubs folder…

The error does not provide any more details on where the wpf file could be imported.

if you run
from pyrevit import revit instead?
trying to pin down where is the wpf import in.

This produces the same error.
Just like running import pyrevit

wpf is in pyrevit.framework module

It is highly dependent on the inner work8ngs of pyrevit.

Not sure what’s going on here, and I’m not sure if we should support rbp at all since we have pyrevit run

You already test the .addin theory by confirming that the script runs in pyrevit gui and cli :wink:

For the rbp not detecting pyrevit dlls theory, I don’t know rbp so I can’t suggest you anything. Is there an option to show more verbose/debug messages?

RBP support would be very nice because RBP is able to close all dialog boxes that pop up when opening models, I think this is still a limitation of pyrevit run?
In my case I have a lot of pyrevit scripts that I would like to run at night unattended, without the risk of it stopping because a random pop up appears.

No, this is everything…

pyrevit doesn’t to anything about it, it’s your script that needs to handle it.

as the documentation tells you, the detachAndPrompt argument of the OpenAndActivateDocument will take care of hiding prompts on workshared models, and the OpenOptions class has other members that can be helpful, too.