Skip to content

Execution StubGeneration

Truong Giang Vu edited this page May 31, 2026 · 1 revision

Python Stub Generation

Python stubs help IDEs understand .NET and Revit API types so autocomplete and type hints are more useful while writing Python scripts.

Use This When

  • VSCode/Pylance cannot infer Revit API types;
  • you want better autocomplete for .NET assemblies;
  • you are writing larger Python scripts and need safer navigation;
  • you want type hints for APIs that Python normally sees dynamically.

What Stubs Help With

Need How stubs help
Discover Revit API members IDE autocomplete can list known members
Reduce typo errors Pylance can flag missing names earlier
Read unfamiliar APIs signatures are easier to inspect
Navigate large scripts type hints improve jump-to-definition behavior

Practical Guidance

Stub generation is an IDE productivity feature. It does not change how a script runs inside RevitDevTool.

For runtime behavior, start with:

Caveats

  • Generated stubs can lag behind the exact API version you use.
  • Some dynamic PythonNet behavior cannot be represented perfectly as static type hints.
  • If a stub disagrees with runtime behavior, trust the runtime and Revit API documentation.

Clone this wiki locally