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
BUILD_STRATEGY_ROSLYN = 'Roslyn'
module-attribute
NEW_LOADER_MIN_REVIT_VERSION = 2021
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
control_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.
Load session now takes a light parameter that will skip the assembly creation and UI creation. This is for the case when pyRevitAssemblyMaker.dll is used to create the assembly and UI
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
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 | |
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('pyrevitcore_pyrevit_pyrevit_tools_reload')
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=True)
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
|