pyrevit

pyRevit root level config for all pyrevit sub-modules.

Examples

>>> from pyrevit import DB, UI
>>> from pyrevit import PyRevitException, PyRevitIOError
>>> # pyrevit module has global instance of the
>>> # _HostAppPostableCommand and _ExecutorParams classes already created
>>> # import and use them like below
>>> from pyrevit import HOST_APP
>>> from pyrevit import EXEC_PARAMS
class pyrevit.PyRevitException

Common base class for all pyRevit exceptions.

Parameters args and message are derived from Exception class.

class pyrevit.PyRevitIOError

Common base class for all pyRevit io-related exceptions.

class pyrevit._HostAppPostableCommand(name, key, id, rvtobj)

Private namedtuple for passing information about a PostableCommand

name

Postable command name

Type:str
key

Postable command key string

Type:str
id

Postable command id

Type:int
rvtobj

Postable command Id Object

Type:RevitCommandId
class pyrevit._HostApplication(host_uiapp)

Private Wrapper for Current Instance of Revit.

Provides version info and comparison functionality, alongside providing info on the active screen, active document and ui-document, available postable commands, and other functionality.

Parameters:host_uiapp (UIApplication) – Instance of running host.

Example

>>> hostapp = _HostApplication(__revit__)
>>> hostapp.is_newer_than(2017)
activeview

Return view that is active (UIDocument.ActiveView).

app

Return Application provided to the running command.

available_servers

Return list of available Revit server names.

build

Return build number (e.g. ‘20170927_1515(x64)’).

Type:str
doc

Return active Document.

docs

Return list of open Document objects.

get_postable_commands()

Return list of postable commands.

Returns:list of _HostAppPostableCommand
is_exactly(version)

bool: Return True if host app is equal to provided version.

Parameters:version (str or int) – version to check against.
is_newer_than(version, or_equal=False)

bool: Return True if host app is newer than provided version.

Parameters:version (str or int) – version to check against.
is_older_than(version)

bool: Return True if host app is older than provided version.

Parameters:version (str or int) – version to check against.
proc

Return current process object.

Type:System.Diagnostics.Process
proc_id

Return current process id.

Type:int
proc_name

Return current process name.

Type:str
proc_path

Return file path for the current process main module.

Type:str
proc_screen

Return handle to screen hosting current process.

Type:intptr
proc_screen_scalefactor

Return scaling for screen hosting current process.

Type:float
proc_screen_workarea

Return screen working area.

Type:System.Drawing.Rectangle
proc_window

Return handle to screen hosting current process.

Type:intptr
subversion

Return subversion number (e.g. ‘2018.3’).

Type:str
uiapp

Return UIApplication provided to the running command.

uidoc

Return active UIDocument.

username

Return the username from Revit API (Application.Username).

Type:str
version

Return version number (e.g. ‘2018’).

Type:str
version_name

Return version name (e.g. ‘Autodesk Revit 2018’).

Type:str
class pyrevit._ExecutorParams

Private Wrapper that provides runtime environment info.

command_alt_path

Return current command alternate script path.

Type:str
command_bundle

Return current command bundle name.

Type:str
command_data

Return current command data.

Type:ExternalCommandData
command_extension

Return current command extension name.

Type:str
command_mode

Check if pyrevit is running in pyrevit command context.

Type:bool
command_name

Return current command name.

Type:str
command_path

Return current command path.

Type:str
command_uniqueid

Return current command unique id.

Type:str
doc_mode

Check if pyrevit is running by doc generator.

Type:bool
engine_mgr

Return engine manager.

Type:PyRevitBaseClasses.EngineManager
engine_ver

Return PyRevitLoader.ScriptExecutor hardcoded version.

Type:str
executed_from_ui

Check if command was executed from ui.

Type:bool
first_load

Check whether pyrevit is not running in pyrevit command.

Type:bool
forced_debug_mode

Check if command is in debug mode.

Type:bool
pyrevit_command

Return command.

Type:PyRevitBaseClasses.PyRevitCommandRuntime
result_dict

Return results dict for logging.

Type:Dictionary<String, String>
window_handle

Return output window.

Type:PyRevitBaseClasses.ScriptOutput