The loader module manages the workflow of loading a new pyRevit session. It’s main purpose is to orchestrate the process of finding pyRevit extensions, creating dll assemblies for them, and creating a user interface in the host application.

Everything starts from sessionmgr.load_session() function…

The only public function is load_session() that loads a new session. Everything else is private.

class pyrevit.loader.sessionmgr.AssembledExtension(ext, assm)

Alias for field number 1


Alias for field number 0


Executes a pyRevit command.

Parameters:pyrevitcmd_unique_id (str) – Unique/Class Name of the pyRevit command
Returns:results from the executed command
pyrevit.loader.sessionmgr.execute_extension_startup_script(script_path, ext_name, sys_paths=None)

Executes a script using pyRevit script executor.

Parameters:script_path (str) – Address of the script file
Returns:results dictionary from the executed script

Searches the pyRevit-generated assemblies under current session for the command with the matching unique name (class name) and returns the command type. Notice that this returned value is a ‘type’ and should be instantiated before use.


>>> cmd = find_pyrevitcmd('pyRevitCorepyRevitpyRevittoolsReload')
>>> command_instance = cmd()
>>> command_instance.Execute() # Provide commandData, message, elements
Parameters:pyrevitcmd_unique_id (str) – Unique name for the command
Returns:Type for the command with matching unique name

Handles loading/reloading of the pyRevit addin and extensions. To create a proper ui, pyRevit extensions needs to be properly parsed and a dll assembly needs to be created. This function handles these tasks through interactions with .extensions, .loader.asmmaker, and .loader.uimaker


>>> from pyrevit.loader.sessionmgr import load_session
>>> load_session()     # start loading a new pyRevit session