sessionmgr
The loader module manages the workflow of loading a new pyRevit session.
Its 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.
Attributes
mlogger = logger.get_logger(__name__)
module-attribute
AssembledExtension = namedtuple('AssembledExtension', ['ext', 'assm'])
module-attribute
pyrevit_extcmdtype_cache = []
module-attribute
Classes
PyRevitExternalCommandType(extcmd_type, extcmd_availtype)
Bases: object
PyRevit external command type.
Source code in pyrevitlib/pyrevit/loader/sessionmgr.py
Attributes
extcmd_type
property
typename
property
extcmd_availtype
property
avail_typename
property
script
property
config_script
property
search_paths
property
arguments
property
engine_cfgs
property
helpsource
property
tooltip
property
name
property
bundle
property
extension
property
unique_id
property
Functions
is_available(category_set, zerodoc=False)
Functions
load_session()
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.
Examples:
from pyrevit.loader.sessionmgr import load_session
load_session() # start loading a new pyRevit session
Returns:
Type | Description |
---|---|
str
|
sesion uuid |
Source code in pyrevitlib/pyrevit/loader/sessionmgr.py
reload_pyrevit()
find_all_commands(category_set=None, cache=True)
Source code in pyrevitlib/pyrevit/loader/sessionmgr.py
find_all_available_commands(use_current_context=True, cache=True)
find_pyrevitcmd(pyrevitcmd_unique_id)
Find a pyRevit command.
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.
Examples:
cmd = find_pyrevitcmd('pyRevitCorepyRevitpyRevittoolsReload')
command_instance = cmd()
command_instance.Execute() # Provide commandData, message, elements
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pyrevitcmd_unique_id |
str
|
Unique name for the command |
required |
Returns:
Type | Description |
---|---|
type
|
Type for the command with matching unique name |
Source code in pyrevitlib/pyrevit/loader/sessionmgr.py
create_tmp_commanddata()
Source code in pyrevitlib/pyrevit/loader/sessionmgr.py
execute_command_cls(extcmd_type, arguments=None, config_mode=False, exec_from_ui=False)
Source code in pyrevitlib/pyrevit/loader/sessionmgr.py
execute_command(pyrevitcmd_unique_id)
Executes a pyRevit command.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pyrevitcmd_unique_id |
str
|
Unique/Class Name of the pyRevit command |
required |
Source code in pyrevitlib/pyrevit/loader/sessionmgr.py
execute_extension_startup_script(script_path, ext_name, sys_paths=None)
Executes a script using pyRevit script executor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
script_path |
str
|
Address of the script file |
required |
ext_name |
str
|
Name of the extension |
required |
sys_paths |
list
|
additional search paths |
None
|