pyRevit 4.8 Documentation Guide
pyRevit 4.8 Documentation Guide
Release 4.8.12.22247+0031
eirannejad
1 pyrevit 3
2 [Link] 9
3 [Link] 11
4 [Link] 13
4.1 [Link] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.2 [Link] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.3 [Link] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.4 [Link] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.5 [Link] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.6 [Link] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.7 [Link] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.8 [Link] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.9 [Link] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.10 [Link] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.11 [Link] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
5 [Link] 53
5.1 [Link] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
5.2 [Link] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
6 [Link] 79
7 [Link] 81
7.1 [Link] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
7.2 [Link] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
7.3 [Link] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
7.4 [Link] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
7.5 [Link] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
8 [Link] 85
8.1 [Link] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
9 [Link] 93
9.1 [Link] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
9.2 [Link] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
i
9.3 [Link] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
9.4 [Link] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
10 [Link] 97
10.1 [Link] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
11 [Link] 101
12 [Link] 109
13 [Link] 113
13.1 [Link] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
13.2 [Link] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
13.3 [Link] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
Index 119
ii
pyRevit Documentation, Release 4.8.12.22247+0031
Getting Started
I suggest reading this section completely as it provides 99% of what you will need to know for developing scripts in
pyRevit environment. Other sections dive deeper into pyRevit inner workings.
pyRevit Module
• pyrevit
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
pyRevit Module 1
pyRevit Documentation, Release 4.8.12.22247+0031
2 pyRevit Module
CHAPTER 1
pyrevit
Examples
class [Link]
Common base class for all pyRevit exceptions.
Parameters args and message are derived from Exception class.
class [Link]
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
3
pyRevit Documentation, Release 4.8.12.22247+0031
Type int
rvtobj
Postable command Id Object
Type RevitCommandId
class pyrevit._HostApplication
Private Wrapper for Current Instance of Revit.
Provides version info and comparison functionality, alongside providing info on the active screen, active docu-
ment and ui-document, available postable commands, and other functionality.
Parameters host_uiapp (UIApplication) – Instance of running host.
Example
active_view
Return view that is active ([Link]).
addin_id
Return active addin id.
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
has_api_context
Determine if host application is in API context
is_demo
Determine if product is using demo license.
Type bool
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.
4 Chapter 1. pyrevit
pyRevit Documentation, Release 4.8.12.22247+0031
5
pyRevit Documentation, Release 4.8.12.22247+0031
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 ([Link]).
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.
cached_engine
Check whether pyrevit is running on a cached engine.
Type bool
command_bundle
Return current command bundle name.
Type str
command_config_path
Return current command config script path.
Type str
command_controlid
Return current command control id.
Type str
command_data
Return current command data.
Type ExternalCommandData
command_elements
Return elements passed to by Revit.
Type [Link]
command_extension
Return current command extension name.
Type str
command_mode
Check if pyrevit is running in pyrevit command context.
6 Chapter 1. pyrevit
pyRevit Documentation, Release 4.8.12.22247+0031
Type bool
command_name
Return current command name.
Type str
command_path
Return current command path.
Type str
command_uibutton
Return current command ui button.
Type str
command_uniqueid
Return current command unique id.
Type str
config_mode
Check if command is in config mode.
Type bool
debug_mode
Check if command is in debug mode.
Type bool
doc_mode
Check if pyrevit is running by doc generator.
Type bool
engine_cfgs
Return [Link]
engine_id
Return engine id
engine_ver
Return [Link] hardcoded version.
Type str
event_args
Return event arguments object.
Type [Link]
event_doc
Return document set in event args if available.
Type [Link]
event_sender
Return event sender object.
Type Object
exec_id
Return execution unique id
7
pyRevit Documentation, Release 4.8.12.22247+0031
exec_timestamp
Return execution timestamp
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
needs_clean_engine
Check if command needs a clean IronPython engine.
Type bool
needs_fullframe_engine
Check if command needs a full-frame IronPython engine.
Type bool
needs_persistent_engine
Check if command needs a persistent IronPython engine.
Type bool
needs_refreshed_engine
Check if command needs a newly refreshed IronPython engine.
Type bool
output_stream
Return ScriptIO
result_dict
Return results dict for logging.
Type Dictionary<String, String>
script_data
Return [Link]
script_runtime
Return command.
Type [Link]
script_runtime_cfgs
Return [Link]
window_handle
Return output window. handle
Type [Link]
8 Chapter 1. pyrevit
CHAPTER 2
[Link]
Example
[Link].get_product_serial_number()
Return serial number of running host instance.
[Link].is_api_object(data_type)
Check if given object belongs to Revit API
[Link].is_product_demo()
Determine if product is using demo license
9
pyRevit Documentation, Release 4.8.12.22247+0031
10 Chapter 2. [Link]
CHAPTER 3
[Link]
Example
11
pyRevit Documentation, Release 4.8.12.22247+0031
12 Chapter 3. [Link]
CHAPTER 4
[Link]
4.1 [Link]
Example
[Link].cleanup_appdata_folder()
Cleanup appdata folder of all temporary appdata files.
[Link].find_data_files(file_ext)
Find data files in all data files directories
Parameters file_ext (str) – data files with this extension will be listed only
Returns list of files
Return type list
[Link].find_instance_data_files(file_ext, instance_id)
Find instance data files in all data files directories
Parameters
• file_ext (str) – data files with this extension will be listed only
• instance_id (int) – list data files for this instance id only
Returns list of files
13
pyRevit Documentation, Release 4.8.12.22247+0031
14 Chapter 4. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
4.2 [Link]
4.2. [Link] 15
pyRevit Documentation, Release 4.8.12.22247+0031
chart_type
chart type name
Type str
draw()
Request chart to draw itself on output window.
randomize_colors()
Randomize chart datasets colors.
set_height(height)
Set chart height on output window.
set_style(html_style)
Set chart styling.
Parameters html_style (str) – inline html css styling string
Example
>>> chart.set_style('height:150px')
set_width(width)
Set chart width on output window.
class [Link]
Bases: object
Chart data wrapper object.
new_dataset(dataset_label)
Create new data set.
Parameters dataset_label (str) – dataset label
Returns dataset wrapper object
Return type PyRevitOutputChartDataset
Example
>>> [Link].new_dataset('set_a')
class [Link](label)
Bases: object
Chart dataset wrapper object.
set_color(*args)
Set dataset color.
Arguments are expected to be R, G, B, A values.
Example
16 Chapter 4. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
class [Link]
Bases: object
Chart options wrapper object.
4.3 [Link]
Provide RGB color constants and a colors dictionary with elements formatted: COLORS[colorname] = CONSTANT
Example
# color consts
ALICEBLUE = RGB(name='aliceblue', red=240, green=248, blue=255)
ANTIQUEWHITE = RGB(name='antiquewhite', red=250, green=235, blue=215)
ANTIQUEWHITE1 = RGB(name='antiquewhite1', red=255, green=239, blue=219)
ANTIQUEWHITE2 = RGB(name='antiquewhite2', red=238, green=223, blue=204)
(continues on next page)
4.3. [Link] 17
pyRevit Documentation, Release 4.8.12.22247+0031
18 Chapter 4. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
4.3. [Link] 19
pyRevit Documentation, Release 4.8.12.22247+0031
20 Chapter 4. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
4.3. [Link] 21
pyRevit Documentation, Release 4.8.12.22247+0031
22 Chapter 4. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
4.3. [Link] 23
pyRevit Documentation, Release 4.8.12.22247+0031
24 Chapter 4. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
4.3. [Link] 25
pyRevit Documentation, Release 4.8.12.22247+0031
26 Chapter 4. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
4.4 [Link]
4.4. [Link] 27
pyRevit Documentation, Release 4.8.12.22247+0031
get_section(section_name)
Get section with given name.
Raises AttributeError – if section is missing
has_section(section_name)
Check if config contains given section.
reload(cfg_file_path=None)
Reload config from original or given file.
remove_section(section_name)
Remove section from config.
save(cfg_file_path=None)
Save config to original or given file.
class [Link](config_parser,
sec-
tion_name)
Bases: object
Config section parser object. Handle section options.
add_subsection(section_name)
Add subsection to section.
get_option(op_name, default_value=None)
Get option value or return default.
get_subsection(section_name)
Get subsection with given name.
get_subsections()
Get all subsections.
has_option(option_name)
Check if section contains given option.
has_subsection(section_name)
Check if section has any subsections.
header
Section header.
remove_option(option_name)
Remove given option from section.
set_option(op_name, value)
Set value of given option.
subheader
Section sub-header e.g. [Link]
4.5 [Link]
28 Chapter 4. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
Some settings needs to be set for the current session and might need to affect the behaviour of all individual scripts
inside the extensions. (e.g. If user activates the DEBUG mode, all scripts should follow and log the debug entries.)
The information is saved using [Link] and SetData in a dictionary parameter. The dictionary is
used to minimize the addition of named parameters to the AppDomain. The dictionary then includes all the internal
parameters and their associated value. This way each script does not need to read the usersettings data which reduces
io and saves time.
pyRevit uses environment variables extensively at its core and making changes to the core environment variables
(starting with PYREVIT_) through scripts is strongly prohibited.
Example
Then another script or same script when executed later within the same session can query the shared environment
variable:
>>> envvars.get_pyrevit_env_vars('MY_SCRIPT_STATUS')
True
>>> envvars.get_pyrevit_env_vars('MY_SCRIPT_CONFIG')
{'someconfig': True}
[Link].get_pyrevit_env_var(param_name)
Get value of a parameter shared between all scripts.
Parameters param_name (str) – name of environment variable
Returns any object stored as the environment variable value
Return type object
[Link].get_pyrevit_env_vars()
Get the root dictionary, holding all environment variables.
[Link].set_pyrevit_env_var(param_name, param_value)
Set value of a parameter shared between all scripts.
Parameters
• param_name (str) – name of environment variable
• param_value (object) – any python object
4.6 [Link]
4.6. [Link] 29
pyRevit Documentation, Release 4.8.12.22247+0031
30 Chapter 4. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
4.7 [Link]
4.7. [Link] 31
pyRevit Documentation, Release 4.8.12.22247+0031
get_level()
Return current logging level.
has_errors()
Check if logger has reported any errors.
isEnabledFor(level)
Override [Link]
is_enabled_for(level)
Check if logger is enabled for level in pyRevit environment.
reset_level()
Reset logging level back to default.
set_debug_mode()
Activate debug mode. Log levels >= DEBUG are enabled.
set_level(level)
Set logging level to level.
set_quiet_mode()
Activate quiet mode. All log levels are disabled.
set_verbose_mode()
Activate verbose mode. Log levels >= INFO are enabled.
[Link].get_file_hndlr()
Return file logging handler object.
Returns configured instance of python’s native stream handler
Return type [Link]
[Link].get_logger(logger_name)
Register and return a logger with given name.
Caches all registered loggers and returns the same logger object on second call with the same logger name.
Parameters
• logger_name (str) – logger name
• val (type) – desc
Returns logger object wrapper python’s native logger
Return type LoggerWrapper
Example
[Link].get_stdout_hndlr()
Return stdout logging handler object.
Returns configured instance of python’s native stream handler
Return type [Link]
[Link].loggers_have_errors()
Check if any errors have been reported by any of registered loggers.
32 Chapter 4. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
[Link].set_file_logging(status)
Set file logging status (enable/disable).
Parameters status (bool) – True to enable, False to disable
4.8 [Link]
Example
4.9 [Link]
4.8. [Link] 33
pyRevit Documentation, Release 4.8.12.22247+0031
4.10 [Link]
Example
Example
copy()
Copy the dictionary.
[Link].almost_equal(a, b, rnd=5)
Check if two numerical values almost equal
Parameters
• a (float) – value a
• b (float) – value b
• rnd (int, optional) – n digits after comma. Defaults to 5.
Returns True if almost equal
Return type bool
[Link].compare_lists(x, y)
Compare two lists.
See: [Link]
Parameters
• x (list) – first list
• y (list) – second list
34 Chapter 4. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
[Link](token)
Verify if given string token is int or float.
Parameters token (str) – string value
Returns True of token is int or float
Return type bool
Example
>>> isnumber('12.3')
True
[Link](d1, d2)
Merge d2 into d1.
d2 dict values are recursively merged into d1 dict values other d2 values are added to d1 dict values with the
same key new d2 values are added to d1 d2 values override other d1 values
Parameters
• d1 (dict) – dict to be updated
• d2 (dict) – dict to be merge into d1
Returns updated d1
Return type dict
Example
[Link](iterable, step=2)
Iterate through items in pairs.
Parameters
• iterable (iterable) – any iterable object
• step (int) – number of steps to move when making pairs
Returns list of pairs
Return type iterable
Example
4.10. [Link] 35
pyRevit Documentation, Release 4.8.12.22247+0031
Example
4.11 [Link]
36 Chapter 4. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
4.11. [Link] 37
pyRevit Documentation, Release 4.8.12.22247+0031
get_adwindows_object()
Return underlying AdWindows API object for this container.
get_flagged_children(state=True)
Get all children with their flag equal to given state.
Flagging is a mechanism to mark certain containers. There are various reasons that container flagging
might be used e.g. marking updated containers or the ones in need of an update or removal.
Parameters state (bool) – flag state to filter children
Returns list of filtered child objects
Return type list[*]
get_rvtapi_object()
Return underlying Revit API object for this container.
is_dirty()
Is dirty flag set.
static is_native()
Is this container generated by pyRevit or is native.
reorder_after(item_name, ritem_name)
Reorder and place item_name after ritem_name
Parameters
• item_name (str) – name of component to be moved
• ritem_name (str) – name of component that should be on the left
reorder_afterall(item_name)
Reorder and place item_name after all others.
Parameters item_name (str) – name of component to be moved
reorder_before(item_name, ritem_name)
Reorder and place item_name before ritem_name
Parameters
• item_name (str) – name of component to be moved
• ritem_name (str) – name of component that should be on the right
reorder_beforeall(item_name)
Reorder and place item_name before all others.
Parameters item_name (str) – name of component to be moved
set_dirty_flag(state=True)
Set dirty flag to given state.
See .get_flagged_children()
Parameters state (bool) – state to set flag
set_rvtapi_object(rvtapi_obj)
Set underlying Revit API object for this container.
Parameters rvtapi_obj (obj) – Revit API container object
visible
Is container visible.
38 Chapter 4. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
class [Link]
Bases: [Link]
Common base type for native Revit API UI containers.
activate()
Activate this container in ui.
Under current implementation, raises PyRevitUIError exception as native Revit API UI components should
not be changed.
deactivate()
Deactivate this container in ui.
Under current implementation, raises PyRevitUIError exception as native Revit API UI components should
not be changed.
static is_native()
Is this container generated by pyRevit or is native.
exception [Link]
Bases: [Link]
Common base class for all pyRevit ui-related exceptions.
class [Link](adwnd_ribbon_button)
Bases: [Link]
Revit API UI native ribbon button.
class [Link](adwnd_ribbon_item)
Bases: [Link]
Revit API UI native ribbon button.
button(name)
Get button item with given name.
Parameters name (str) – name of button item to find
Returns button object if found
Return type RevitNativeRibbonButton
class [Link](adwnd_ribbon_panel)
Bases: [Link]
Revit API UI native ribbon button.
ribbon_item(item_name)
Get panel item with given name.
Parameters item_name (str) – name of panel item to find
Returns panel item if found, could be RevitNativeRibbonButton or
RevitNativeRibbonGroupItem
Return type object
class [Link](adwnd_ribbon_tab)
Bases: [Link]
Revit API UI native ribbon tab.
static is_pyrevit_tab()
Is this tab generated by pyRevit.
4.11. [Link] 39
pyRevit Documentation, Release 4.8.12.22247+0031
ribbon_panel(panel_name)
Get panel with given name.
Parameters panel_name (str) – name of panel to find
Returns panel if found
Return type RevitNativeRibbonPanel
[Link].get_current_ui(all_native=False)
Revit UI Wrapper class for interacting with current pyRevit UI.
Returned class provides min required functionality for user interaction
Example
[Link].get_uibutton(command_unique_name)
Find and return ribbon ui button with given unique id.
Parameters command_unique_name (str) – unique id of pyRevit command
Returns ui button wrapper object
Return type _PyRevitRibbonButton
[Link].load_bitmapimage(image_file)
Load given png file.
Parameters image_file (str) – image file path
Returns bitmap image object
Return type [Link]
Misc Helper functions for pyRevit.
Example
class [Link](filepath)
Bases: object
Simple file version watcher.
This is a simple utility class to look for changes in a file based on its timestamp.
40 Chapter 4. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
Example
has_changed
Compare current file timestamp to the cached timestamp.
update_tstamp()
Update the cached timestamp for later comparison.
class [Link]
Bases: dict
Dictionary that does not fail on any key.
This is a dictionary subclass to help with string formatting with unknown key values.
Example
class [Link](file_address)
Bases: object
Parse python script to extract variables and docstrings.
Primarily designed to assist pyRevit in determining script configurations but can work for any python script.
Example
extract_node_value(node)
Manual extraction of values from node
extract_param(param_name, default_value=None)
Find variable and extract its value.
Parameters
• param_name (str) – variable name
• default_value (any) – default value to be returned if variable does not exist
Returns value of the variable or None
Return type any
4.11. [Link] 41
pyRevit Documentation, Release 4.8.12.22247+0031
get_docstring()
Get global docstring.
class [Link]
Bases: object
Timer class using python native time module.
Example
get_time()
Get Elapsed Time.
restart()
Restart Timer.
[Link].calculate_dir_hash(dir_path, dir_filter, file_filter)
Create a unique hash to represent state of directory.
Parameters
• dir_path (str) – target directory
• dir_filter (str) – exclude directories matching this regex
• file_filter (str) – exclude files matching this regex
Returns hash value as string
Return type str
Example
[Link].can_access_url(url_to_open, timeout=1000)
Check if url is accessible within timeout.
Parameters
• url_to_open (str) – url to check access for
• timeout (int) – timeout in milliseconds
Returns true if accessible
Return type bool
[Link].check_encoding_bom(filename, bom_bytes=’\xef\xbb\xbf’)
Check if given file contains the given BOM bytes at the start
Parameters
• filename (str) – file path
• bom_bytes (bytes, optional) – BOM bytes to check
42 Chapter 4. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
[Link].check_internet_connection(timeout=1000)
Check if internet connection is available.
Pings a few well-known websites to check if internet connection is present.
Parameters timeout (int) – timeout in milliseconds
Returns url if internet connection is present, None if no internet.
[Link].cleanup_filename(file_name, windows_safe=False)
Cleanup file name from special characters.
Parameters file_name (str) – file name
Returns cleaned up file name
Return type str
Example
>>> cleanup_filename('Myfile-(3).txt')
"Myfile(3).txt"
[Link].cleanup_string(input_str, skip=None)
Replace special characters in string with another string.
This function was created to help cleanup pyRevit command unique names from any special characters so C#
class names can be created based on those unique names.
coreutils.SPECIAL_CHARS is the conversion table for this function.
Parameters input_str (str) – input string to be cleaned
Example
[Link].current_date()
Return formatted current date.
Current implementation uses %Y-%m-%d to format date.
Returns formatted current date.
Return type str
Example
>>> current_date()
'2018-01-03'
4.11. [Link] 43
pyRevit Documentation, Release 4.8.12.22247+0031
[Link].current_time()
Return formatted current time.
Current implementation uses %H:%M:%S to format time.
Returns formatted current time.
Return type str
Example
>>> current_time()
'07:50:53'
Example
>>> decrement_str('A310a')
'A309z'
[Link].dletter_to_unc(dletter_path)
Convert drive letter path into UNC path of that drive.
Parameters dletter_path (str) – drive letter path
Returns UNC path
Return type str
Example
44 Chapter 4. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
Example
>>> extend_counter('A310')
'A310A'
>>> extend_counter('A310A', use_zero=True)
'A310A0'
[Link].extract_guid(source_str)
Extract GUID number from a string.
[Link].extract_range(formatted_str, max_range=500)
Extract range from formatted string.
String must be formatted as below A103 No range A103-A106 A103 to A106 A103:A106 A103 to A106
A103,A105a A103 and A105a A103;A105a A103 and A105a
Parameters formatted_str (str) – string specifying range
Returns list of names in the specified range
Return type list
Example
>>> exract_range('A103:A106')
['A103', 'A104', 'A105', 'A106']
>>> exract_range('S203-S206')
['S203', 'S204', 'S205', 'S206']
>>> exract_range('M00A,M00B')
['M00A', 'M00B']
[Link].filter_null_items(src_list)
Remove None items in the given list.
Parameters src_list (list) – list of any items
Returns cleaned list
Return type list
[Link].format_hex_rgb(rgb_value)
Formats rgb value as #RGB value string.
[Link].fully_remove_dir(dir_path)
Remove directory recursively.
Parameters dir_path (str) – directory path
[Link].fuzzy_search_ratio(target_string, sfilter, regex=False)
Match target string against the filter and return a match ratio.
Parameters
• target_string (str) – target string
• sfilter (str) – search term
• regex (bool) – treat the sfilter as regular expression pattern
4.11. [Link] 45
pyRevit Documentation, Release 4.8.12.22247+0031
Returns integer between 0 to 100, with 100 being the exact match
Return type int
[Link].get_all_subclasses(parent_classes)
Return all subclasses of a python class.
Parameters parent_classes (list) – list of python classes
Returns list of python subclasses
Return type list
[Link].get_canonical_parts(canonical_string)
Splots argument using dot, returning all composing parts.
Parameters canonical_string (str) – Source string e.g. “[Link]”
Returns list of composing parts
Return type list[str]
Example
>>> get_canonical_parts("[Link]")
['Config', 'SubConfig']
[Link].get_enum_none(enum_type)
Returns the None value in given Enum.
[Link].get_enum_value(enum_type, value_string)
Return enum value matching given value string (case insensitive)
[Link].get_enum_values(enum_type)
Returns enum values.
[Link].get_exe_version(exepath)
Extract Product Version value from EXE file.
[Link].get_file_name(file_path)
Return file basename of the given file.
Parameters file_path (str) – file path
[Link].get_integer_length(number)
Return digit length of given number.
[Link].get_mapped_drives_dict()
Return a dictionary of currently mapped network drives.
[Link].get_my_ip()
Return local ip address of this machine
[Link].get_paper_sizes(printer_name=None)
Get paper sizes defined on this system
Returns list of papersize instances
Return type list[]
[Link].get_reg_key(key, subkey)
Get value of the given Windows registry key and subkey.
Parameters
46 Chapter 4. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
Example
[Link].get_revit_instance_count()
Return number of open host app instances.
Returns number of open host app instances.
Return type int
[Link].get_str_hash(source_str)
Calculate hash value of given string.
Current implementation uses hashlib.md5() hash function.
Parameters source_str (str) – source str
Returns hash value as string
Return type str
[Link].get_sub_folders(search_folder)
Get a list of all subfolders directly inside provided folder.
Parameters search_folder (str) – folder path
Returns list of subfolder names
Return type list
[Link].has_nonprintable(input_str)
Check input string for non-printable characters.
Parameters input_str (str) – input string
Returns True if contains non-printable characters
Return type bool
[Link].hex2int_long(hex_string)
Hexadecimal string to Integer.
[Link].increment_str(input_str, step=1, expand=False)
Incremenet identifier.
Parameters
• input_str (str) – identifier e.g. A310a
• step (int) – number of steps to change the identifier
Returns modified identifier
Return type str
4.11. [Link] 47
pyRevit Documentation, Release 4.8.12.22247+0031
Example
>>> increment_str('A319z')
'A320a'
[Link].inspect_calling_scope_global_var(variable_name)
Trace back the stack to find the variable in the caller global stack.
Parameters variable_name (str) – variable name to look up in caller global scope
[Link].inspect_calling_scope_local_var(variable_name)
Trace back the stack to find the variable in the caller local stack.
PyRevitLoader defines __revit__ in builtins and __window__ in locals. Thus, modules have access to __revit__
but not to __window__. This function is used to find __window__ in the caller stack.
Parameters variable_name (str) – variable name to look up in caller local scope
[Link].int2hex_long(number)
Integer to hexadecimal string.
[Link].is_blank(input_string)
Check if input string is blank (multiple white spaces is blank).
Parameters input_string (str) – input string
Returns True if string is blank
Return type bool
Example
Example
>>> is_url_valid('[Link]
True
[Link].join_strings(str_list, separator=’;’)
Join strings using provided separator.
Parameters
• str_list (list) – list of string values
• separator (str) – single separator character, defaults to DEFAULT_SEPARATOR
48 Chapter 4. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
Example
>>> kill_tasks('[Link]')
[Link].make_canonical_name(*args)
Join arguments with dot creating a unique id.
Parameters *args – Variable length argument list of type str
Returns dot separated unique name
Return type str
Example
[Link].new_uuid()
Create a new UUID (using dotnet [Link])
[Link].open_folder_in_explorer(folder_path)
Open given folder in Windows Explorer.
Parameters folder_path (str) – directory path
[Link].prepare_html_str(input_string)
Reformat html string and prepare for pyRevit output window.
pyRevit output window renders html content. But this means that < and > characters in outputs from python
(e.g. <class at xxx>) will be treated as html tags. To avoid this, all <> characters that are defining html content
need to be replaced with special phrases. pyRevit output later translates these phrases back in to < and >. That
is how pyRevit distinquishes between <> printed from python and <> that define html.
Parameters input_string (str) – input html string
Example
[Link].random_alpha()
Return a random alpha value (between 0 and 1.00).
[Link].random_color()
Return a random color channel value (between 0 and 255).
[Link].random_hex_color()
Return a random color in hex format.
4.11. [Link] 49
pyRevit Documentation, Release 4.8.12.22247+0031
Example
>>> random_hex_color()
'#FF0000'
[Link].random_rgb_color()
Return a random color in rgb format.
Example
>>> random_rgb_color()
'rgb(255, 0, 0)'
[Link].random_rgba_color()
Return a random color in rgba format.
Example
>>> random_rgba_color()
'rgba(255, 0, 0, 0.5)'
[Link].read_source_file(source_file_path)
Read text file and return contents.
Parameters source_file_path (str) – target file path
Returns file contents
Return type str
Raises PyRevitException on read error
[Link].read_url(url_to_open)
Get the url and return response.
Parameters url_to_open (str) – url to check access for
[Link].reformat_string(orig_str, orig_format, new_format)
Reformat a string into a new format.
Extracts information from a string based on a given pattern, and recreates a new string based on the given new
pattern.
Parameters
• orig_str (str) – Original string to be reformatted
• orig_format (str) – Pattern of the original str (data to be extracted)
• new_format (str) – New pattern (how to recompose the data)
Returns Reformatted string
Return type str
50 Chapter 4. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
Example
[Link].reverse_dict(input_dict)
Reverse the key, value pairs.
Parameters input_dict (dict) – source ordered dict
Returns reversed dictionary
Return type defaultdict
Example
[Link].reverse_html(input_html)
Reformat codified pyRevit output html string back to normal html.
pyRevit output window renders html content. But this means that < and > characters in outputs from python
(e.g. <class at xxx>) will be treated as html tags. To avoid this, all <> characters that are defining html content
need to be replaced with special phrases. pyRevit output later translates these phrases back in to < and >. That
is how pyRevit distinquishes between <> printed from python and <> that define html.
Parameters input_html (str) – input codified html string
Example
[Link].run_process(proc, cwd=’C:’)
Run shell process silently.
Parameters
• proc (str) – process executive name
• cwd (str) – current working directory
Exmaple:
>>> run_process('[Link]', 'c:/')
[Link].show_entry_in_explorer(entry_path)
Show given entry in Windows Explorer.
Parameters entry_path (str) – directory or file path
[Link].split_words(input_string)
Splits given string by uppercase characters
Parameters input_string (str) – input string
4.11. [Link] 51
pyRevit Documentation, Release 4.8.12.22247+0031
Example
>>> split_words("UIApplication_ApplicationClosing")
... ['UIApplication', 'Application', 'Closing']
[Link]()
Return timestamp for current time.
Returns timestamp in string format
Return type str
Example
>>> timestamp()
'01003075032506808'
[Link](fname, times=None)
Update the timestamp on the given file.
Parameters
• fname (str) – target file path
• times (int) – number of times to touch the file
[Link].unc_to_dletter(unc_path)
Convert UNC path into drive letter path.
Parameters unc_path (str) – UNC path
Returns drive letter path
Return type str
Example
[Link].verify_directory(folder)
Check if the folder exists and if not create the folder.
Parameters folder (str) – path of folder to verify
Returns path of verified folder, equals to provided folder
Return type str
Raises OSError on folder creation error.
52 Chapter 4. [Link]
CHAPTER 5
[Link]
5.1 [Link]
5.2 [Link]
53
pyRevit Documentation, Release 4.8.12.22247+0031
Example
54 Chapter 5. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
Example
A more advanced example of combining command options, on/off switches, and option or switch configuration
options:
handle_click(sender, args)
Handle mouse click.
handle_input_key(sender, args)
Handle keyboard inputs.
process_option(sender, args)
Handle click on command option button.
search_txt_changed(sender, args)
Handle text change in search box.
class [Link](context, title, width, height, **kwargs)
Standard form to get simple values from user.
Args:
Example
select(sender, args)
Process input data and set the response.
string_value_changed(sender, args)
Handle string vlaue update event.
5.2. [Link] 55
pyRevit Documentation, Release 4.8.12.22247+0031
Example
Progress bar title could also be customized to show the current and total progress values. In example below, the
progress bar message will be in format “0 of 100”
56 Chapter 5. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
By default progress bar updates the progress every time the .update_progress method is called. For operations
with a large number of max steps, the gui update process time will have a significate effect on the overall
execution time of the command. In these cases, set the value of step argument to something larger than 1. In
example below, the progress bar updates once per every 10 units of progress.
Progress bar could also be set to indeterminate for operations of unknown length. In this case, the progress bar
will show an infinitely running ribbon:
if cancellable is set on the object, a cancel button will show on the progress bar and .cancelled attribute will be
set on the ProgressBar instance if users clicks on cancel button:
clicked_cancel(sender, args)
Handler for cancel button clicked event.
indeterminate
Progress bar indeterminate state.
reset()
Reset progress value to 0.
title
Progress bar title.
update_progress(new_value, max_value=1)
Update progress bar state with given min, max values.
Parameters
• new_value (float) – current progress value
• max_value (float) – total progress value
class [Link](search_db, width, height, **kwargs)
Standard prompt for pyRevit search.
Parameters
• search_db (list) – list of possible search targets
• search_tip (str) – text to show in grayscale when search box is empty
• switches (str) – list of switches
• width (int) – width of search prompt window
• height (int) – height of search prompt window
Returns matched strings, and dict of switches if provided str: matched string if switches are not
provided.
Return type str, dict
5.2. [Link] 57
pyRevit Documentation, Release 4.8.12.22247+0031
Example
find_direct_match(input_text)
Find direct text matches in search term.
find_word_match(input_text)
Find direct word matches in search term.
handle_kb_key(sender, args)
Handle keyboard input event.
search_input
Current search input.
search_input_parts
Current cleaned up search term.
search_matches
List of matches for the given search term.
search_term
Current cleaned up search term.
search_term_args
Find arguments in search term.
search_term_main
Current cleaned up search term without the listed switches.
search_term_switches
Find matching switches in search term.
search_txt_changed(sender, args)
Handle text changed event.
set_search_results(*args)
Set search results for returning.
classmethod show(search_db, width=600, height=100, **kwargs)
Show search prompt.
update_results_display(fill_match=False)
Update search prompt results based on current input text.
class [Link](context, title, width, height, **kwargs)
Standard form to select from a list of items.
58 Chapter 5. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
Any object can be passed in a list to the context argument. This class wraps the objects passed to context,
in TemplateListItem. This class provides the necessary mechanism to make this form work both for
selecting items from a list, and from a list of checkboxes. See the list of arguments below for additional options
and features.
Parameters
• context (list[str] or dict[list[str]]) – list of items to be selected from
OR dict of list of items to be selected from. use dict when input items need to be grouped
e.g. List of sheets grouped by sheet set.
• title (str, optional) – window title. see super class for defaults.
• width (int, optional) – window width. see super class for defaults.
• height (int, optional) – window height. see super class for defaults.
• button_name (str, optional) – name of select button. defaults to ‘Select’
• name_attr (str, optional) – object attribute that should be read as item name.
• multiselect (bool, optional) – allow multi-selection (uses check boxes). defaults
to False
• info_panel (bool, optional) – show information panel and fill with .description
property of item
• return_all (bool, optional) – return all items. This is handly when some input
items have states and the script needs to check the state changes on all items. This options
works in multiselect mode only. defaults to False
• filterfunc (function) – filter function to be applied to context items.
• resetfunc (function) – reset function to be called when user clicks on Reset button
• group_selector_title (str) – title for list group selector. defaults to ‘List Group’
• default_group (str) – name of defautl group to be selected
Example
5.2. [Link] 59
pyRevit Documentation, Release 4.8.12.22247+0031
This module also provides a wrapper base class TemplateListItem for when the checkbox option is wrap-
ping another element, e.g. a Revit ViewSheet. Derive from this base class and define the name property to
customize how the checkbox is named on the dialog.
button_select(sender, args)
Handle select button click.
check_all(sender, args)
Handle check all button to mark all check boxes as checked.
check_selected(sender, args)
Mark selected checkboxes as checked.
clear_search(sender, args)
Clear search box.
search_txt_changed(sender, args)
Handle text change in search box.
toggle_all(sender, args)
Handle toggle all button to toggle state of all check boxes.
toggle_regex(sender, args)
Activate regex in search
uncheck_all(sender, args)
Handle uncheck all button to mark all check boxes as un-checked.
uncheck_selected(sender, args)
Mark selected checkboxes as unchecked.
use_regex
Is using regex?
class [Link](height=32, **kwargs)
Template context-manager class for creating prompt bars.
Prompt bars are show at the top of the active Revit window and are designed for better prompt visibility.
Parameters
• height (int) – window height
• **kwargs – other arguments to be passed to _setup()
60 Chapter 5. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
update_window()
Update the prompt bar to match Revit window.
class [Link](context, title, width, height, **kwargs)
Base class for pyRevit user input standard forms.
Parameters
• context (any) – window context element(s)
• title (str) – window title
• width (int) – window width
• height (int) – window height
• **kwargs – other arguments to be passed to _setup()
classmethod show(context, title=’User Input’, width=500, height=600, **kwargs)
Show user input window.
Parameters
• context (any) – window context element(s)
• title (str) – window title
• width (int) – window width
• height (int) – window height
• **kwargs (any) – other arguments to be passed to window
class [Link](xaml_source, literal_string=False, handle_esc=True,
set_owner=True)
WPF Window base class for all pyRevit forms.
Parameters
• xaml_source (str) – xaml source filepath or xaml content
• literal_string (bool) – xaml_source contains xaml content, not filepath
• handle_esc (bool) – handle Escape button and close the window
• set_owner (bool) – set the owner of window to host app window
Example
static disable_element(*wpf_elements)
Enable elements.
Parameters *wpf_elements – WPF framework elements to be enabled
5.2. [Link] 61
pyRevit Documentation, Release 4.8.12.22247+0031
static enable_element(*wpf_elements)
Enable elements.
Parameters *wpf_elements – WPF framework elements to be enabled
handle_input_key(sender, args)
Handle keyboard input and close the window on Escape.
handle_url_click(sender, args)
Callback for handling click on package website url
static hide_element(*wpf_elements)
Collapse elements.
Parameters *wpf_elements – WPF framework elements to be collaped
pyrevit_version
Active pyRevit formatted version e.g. ‘4.9-beta’
set_icon(icon_path)
Set window icon to given icon path.
set_image_source(wpf_element, image_file)
Set source file for image element.
Parameters
• element_name ([Link]) – xaml image element
• image_file (str) – image file path
static set_image_source_file(wpf_element, image_file)
Set source file for image element.
Parameters
• element_name ([Link]) – xaml image element
• image_file (str) – image file path
setup_icon()
Setup default window icon.
show(modal=False)
Show window.
show_dialog()
Show modal window.
static show_element(*wpf_elements)
Show collapsed elements.
Parameters *wpf_elements – WPF framework elements to be set to visible.
static toggle_element(*wpf_elements)
Toggle visibility of elements.
Parameters *wpf_elements – WPF framework elements to be toggled.
class [Link](height=32, **kwargs)
Show warning bar at the top of Revit window.
Parameters title (string) – warning bar text
62 Chapter 5. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
Example
Example
5.2. [Link] 63
pyRevit Documentation, Release 4.8.12.22247+0031
Example
[Link].ask_for_color(default=None)
Show system color picker and ask for color
Parameters
• default (str) – default color in HEX ARGB e.g. #ff808080
• val (type) – desc
Returns selected color in HEX ARGB e.g. #ff808080, or None if cancelled
Return type str
Example
>>> forms.ask_for_color()
... '#ff808080'
Example
64 Chapter 5. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
This is a shortcut function that configures GetValueWindow for numbers. kwargs can be used to pass on
other arguments.
Parameters
• default (str) – default unique string. must not be in reserved_values
• min (int) – minimum value on slider
• max (int) – maximum value on slider
• prompt (str) – prompt message
• title (str) – title message
• kwargs (type) – other arguments to be passed to GetValueWindow
Returns selected string value
Return type str
Example
>>> forms.ask_for_string(
... default=50,
... min = 0
... max = 100
... prompt='Select a number:',
... title='test title')
... '50'
Example
>>> forms.ask_for_one_item(
... ['test item 1', 'test item 2', 'test item 3'],
... default='test item 2',
... prompt='test prompt',
... title='test title'
... )
... 'test item 1'
5.2. [Link] 65
pyRevit Documentation, Release 4.8.12.22247+0031
Example
>>> forms.ask_for_string(
... default='some-tag',
... prompt='Enter new tag name:',
... title='Tag Manager')
... 'new-tag'
Example
>>> forms.ask_for_unique_string(
... prompt='Enter a Unique Name',
... title=[Link],
... reserved_values=['Ehsan', 'Gui', 'Guido'],
... owner=self)
... 'unique string'
66 Chapter 5. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
Example
[Link].check_graphicalview(view, exitscript=False)
Verify target view is a graphical view
Parameters
• view ([Link]) – target view
• exitscript (bool) – exit script if returning False
Returns True if view is a graphical view
Return type bool
Example
[Link].check_modeldoc(doc=None, exitscript=False)
Verify document is a not a Model and notify user if not.
Parameters
• doc ([Link]) – target document, current of not provided
• exitscript (bool) – exit script if returning False
Returns True if doc is a Model
Return type bool
5.2. [Link] 67
pyRevit Documentation, Release 4.8.12.22247+0031
Example
[Link].check_modelview(view, exitscript=False)
Verify target view is a model view.
Parameters
• view ([Link]) – target view
• exitscript (bool) – exit script if returning False
Returns True if view is model view
Return type bool
Example
Example
68 Chapter 5. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
Example
>>> forms.inform_wip()
[Link].is_registered_dockable_panel(panel_type)
Check if dockable panel is already registered
Parameters panel_type ([Link]) – dockable panel type
[Link].open_dockable_panel(panel_type_or_id)
Open previously registered dockable panel
Parameters panel_type_or_id ([Link], str) – panel type or id
[Link].pick_excel_file(save=False, title=None)
File pick/save dialog for an excel file.
Parameters
• save (bool) – show file save dialog, instead of file pick dialog
• title (str) – text to show in the title bar
Returns file path
Return type str
[Link].pick_file(file_ext=’*’, files_filter=”, init_dir=”, restore_dir=True, multi_file=False,
unc_paths=False, title=None)
Pick file dialog to select a destination file.
Parameters
• file_ext (str) – file extension
• files_filter (str) – file filter
• init_dir (str) – initial directory
• restore_dir (bool) – restore last directory
• multi_file (bool) – allow select multiple files
• unc_paths (bool) – return unc paths
5.2. [Link] 69
pyRevit Documentation, Release 4.8.12.22247+0031
Example
[Link].pick_folder(title=None, owner=None)
Show standard windows pick folder dialog.
Parameters title (str, optional) – title for the window
Returns folder path
Return type str
class [Link](getter)
Decorator for WPF bound properties
setter(setter)
Descriptor to change the setter on a property.
[Link].register_dockable_panel(panel_type, default_visible=True)
Register dockable panel
Parameters
• panel_type ([Link]) – dockable panel type
• default_visible (bool, optional) – whether panel should be visible by default
[Link].save_excel_file(title=None)
File save dialog for an excel file.
Parameters title (str) – text to show in the title bar
Returns file path
Return type str
[Link].save_file(file_ext=”, files_filter=”, init_dir=”, default_name=”, restore_dir=True,
unc_paths=False, title=None)
Save file dialog to select a destination file for data.
Parameters
• file_ext (str) – file extension
• files_filter (str) – file filter
70 Chapter 5. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
Example
Example
>>> forms.select_family_parameters(
... family_doc,
... title='Select Parameters',
... multiple=True,
... include_instance=True,
... include_type=True
... )
... [<[Link] >, <[Link] >]
5.2. [Link] 71
pyRevit Documentation, Release 4.8.12.22247+0031
Example
Example
72 Chapter 5. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
Parameters
• title (str, optional) – list window title
• button_name (str, optional) – list window button caption
• width (int, optional) – width of list window
• multiselect (bool, optional) – allow multi-selection (uses check boxes). defaults
to True
• filterfunc (function) – filter function to be applied to context items.
Returns list of selected documents
Return type list[[Link]]
Example
Example
>>> forms.select_parameter(
... src_element,
... title='Select Parameters',
... multiple=True,
... include_instance=True,
... include_type=True
... )
... [<ParamDef >, <ParamDef >]
5.2. [Link] 73
pyRevit Documentation, Release 4.8.12.22247+0031
Example
Example
74 Chapter 5. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
Example
Example
5.2. [Link] 75
pyRevit Documentation, Release 4.8.12.22247+0031
Parameters
• title (str, optional) – list window title
• button_name (str, optional) – list window button caption
• no_tb_option (str, optional) – name of option for no title block
• width (int, optional) – width of list window
• multiselect (bool, optional) – allow multi-selection (uses check boxes). defaults
to True
• filterfunc (function) – filter function to be applied to context items.
• doc ([Link], optional) – source document for titleblocks; defaults to active
document
Returns selected titleblock id.
Return type [Link]
Example
Example
76 Chapter 5. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
Example
Example
5.2. [Link] 77
pyRevit Documentation, Release 4.8.12.22247+0031
[Link].toggle_dockable_panel(panel_type_or_id, state)
Toggle previously registered dockable panel
Parameters panel_type_or_id ([Link], str) – panel type or id
78 Chapter 5. [Link]
CHAPTER 6
[Link]
Example
[Link].get_current_thread_id()
Return manageed thread id of current thread.
[Link].get_dll_file(assembly_name)
Return path to given assembly name.
[Link].get_type(fw_object)
Return CLR type of an object.
79
pyRevit Documentation, Release 4.8.12.22247+0031
80 Chapter 6. [Link]
CHAPTER 7
[Link]
7.1 [Link]
location
Alias for field number 1
name
Alias for field number 0
reloading
Alias for field number 2
[Link].create_assembly(extension)
Parameters extension ([Link]) –
Returns:
7.2 [Link]
81
pyRevit Documentation, Release 4.8.12.22247+0031
Example
>>> sessioninfo.get_runtime_info()
[Link].get_session_uuid()
Read session uuid from environment variable.
Returns session uuid string
Return type str
[Link].new_session_uuid()
Create a new uuid for a pyRevit session.
Returns session uuid string
Return type str
[Link].report_env()
Report python version, home directory, config file, etc.
[Link].set_loaded_pyrevit_assemblies(loaded_assm_name_list)
Set the environment variable with list of loaded assemblies.
Parameters
• loaded_assm_name_list (list[str]) – list of assembly names
• val (type) – desc
[Link].set_session_uuid(uuid_str)
Set session uuid on environment variable.
Parameters uuid_str (str) – session uuid string
[Link].setup_runtime_vars()
Setup runtime environment variables with session information.
82 Chapter 7. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
7.3 [Link]
Session diagnostics.
[Link].system_diag()
Verifies system status is appropriate for a pyRevit session.
7.4 [Link]
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 [Link](ext, assm)
assm
Alias for field number 1
ext
Alias for field number 0
[Link].execute_command(pyrevitcmd_unique_id)
Executes a pyRevit command.
Parameters pyrevitcmd_unique_id (str) – Unique/Class Name of the pyRevit command
Returns results from the executed command
[Link].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
[Link].find_pyrevitcmd(pyrevitcmd_unique_id)
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.
Example
7.3. [Link] 83
pyRevit Documentation, Release 4.8.12.22247+0031
[Link].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, .[Link], and .[Link]
Example
Returns None
7.5 [Link]
UI maker.
[Link].update_pyrevit_ui(ui_ext, ext_asm_info, create_beta=False)
Updates/Creates pyRevit ui for the given extension and provided assembly dll address.
Loader base module.
84 Chapter 7. [Link]
CHAPTER 8
[Link]
8.1 [Link]
Example
Example
Here is the source of [Link].get_output(). As you can see this functions calls the pyrevit.
output.get_output() to receive the output wrapper.
85
pyRevit Documentation, Release 4.8.12.22247+0031
def get_output():
"""Return object wrapping output window for current script.
Returns:
:obj:`[Link]`: Output wrapper object
"""
return output.get_output()
class [Link]
Wrapper to interact with the output window.
add_style(style_code, attribs=None)
Inject style tag into current html head of the output window.
Parameters
• style_code (str) – css styling code
• attribs (dict) – dictionary of attribute names and value
Example
center()
Center the output window on the screen
close()
Close the window.
close_others(all_open_outputs=False)
Close all other windows that belong to the current command.
Parameters all_open_outputs (bool) – Close all any other windows if True
debug_mode
Set debug mode on output window and stream.
This will cause the output window to print information about the buffer stream and other aspects of the
output window mechanism.
freeze()
Freeze output content update.
get_head_html()
str: Return inner code of html head element.
get_height()
int: Return current window height.
get_title()
str: Return current window title.
get_width()
int: Return current window width.
hide()
Hide the window.
86 Chapter 8. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
hide_logpanel()
Hide output window logging panel.
hide_progress()
Hide output window progress bar.
indeterminate_progress(state)
Show or hide indeterminate progress bar.
inject_script(script_code, attribs=None, body=False)
Inject script tag into current head (or body) of the output window.
Parameters
• script_code (str) – javascript code
• attribs (dict) – dictionary of attribute names and value
• body (bool, optional) – injects script into body instead of head
Example
Example
Example
8.1. [Link] 87
pyRevit Documentation, Release 4.8.12.22247+0031
insert_divider(level=”)
Add horizontal rule to the output window.
static linkify(element_ids, title=None)
Create clickable link for the provided element ids.
This method, creates the link but does not print it directly.
Parameters
• element_ids (list of ElementId) –
• element_ids – single or multiple ids
• title (str) – tile of the link. defaults to list of element ids
Example
lock_size()
Lock window size.
log_debug(message)
Report DEBUG message into output logging panel.
log_error(message)
Report ERROR message into output logging panel.
log_info(message)
Report INFO message into output logging panel.
log_success(message)
Report SUCCESS message into output logging panel.
log_warning(message)
Report WARNING message into output logging panel.
make_bar_chart(version=None)
PyRevitOutputChart: Return bar chart object.
make_bubble_chart(version=None)
PyRevitOutputChart: Return bubble chart object.
make_chart(version=None)
PyRevitOutputChart: Return chart object.
make_doughnut_chart(version=None)
PyRevitOutputChart: Return dougnut chart object.
make_line_chart(version=None)
PyRevitOutputChart: Return line chart object.
88 Chapter 8. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
make_pie_chart(version=None)
PyRevitOutputChart: Return pie chart object.
make_polar_chart(version=None)
PyRevitOutputChart: Return polar chart object.
make_radar_chart(version=None)
PyRevitOutputChart: Return radar chart object.
make_stacked_chart(version=None)
PyRevitOutputChart: Return stacked chart object.
next_page()
Add hidden next page tag to the output window.
This is helpful to silently separate the output to multiple pages for better printing.
open_page(dest_file)
Open html page in output window.
Parameters dest_file (str) – full path of the target html file
open_url(dest_url)
Open url page in output window.
Parameters dest_url (str) – web url of the target page
output_id
Return id of the output window.
In current implementation, Id of output window is equal to the unique id of the pyRevit command it
belongs to. This means that all output windows belonging to the same pyRevit command, will have
identical output_id values.
Type str
output_uniqueid
Return unique id of the output window.
In current implementation, unique id of output window is a GUID string generated when the output window
is opened. This id is unique to the instance of output window.
Type str
static print_code(code_str)
Print code to the output window with special formatting.
Example
static print_html(html_str)
Add the html code to the output window.
Example
8.1. [Link] 89
pyRevit Documentation, Release 4.8.12.22247+0031
print_image(image_path)
Prints given image to the output.
Example
static print_md(md_str)
Process markdown code and print to output window.
Example
Example
>>> data = [
... ['row1', 'data', 'data', 80 ],
... ['row2', 'data', 'data', 45 ],
... ]
>>> output.print_table(
... table_data=data,
... title="Example Table",
... columns=["Row Name", "Column 1", "Column 2", "Percentage"],
... formats=['', '', '', '{}%'],
... last_line_style='color:red;'
... )
renderer
Return html renderer inside output window.
Returns [Link] (In current implementation)
reset_icon()
Sets icon on the output window.
reset_progress()
Reset output window progress bar to zero.
90 Chapter 8. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
resize(width, height)
Resize window to the new width and height.
save_contents(dest_file)
Save html code of the window.
Parameters dest_file (str) – full path of the destination html file
self_destruct(seconds)
Set self-destruct (close window) timer.
Parameters seconds (int) – number of seconds after which window is closed.
set_font(font_family, font_size)
Set window font family to the new font family and size.
Parameters
• font_family (str) – font family name e.g. ‘Courier New’
• font_size (int) – font size e.g. 16
set_height(height)
Set window height to the new height.
set_icon(iconpath)
Sets icon on the output window.
set_title(new_title)
Set window title to the new title.
set_width(width)
Set window width to the new width.
show()
Show the window.
show_logpanel()
Show output window logging panel.
unfreeze()
Unfreeze output content update.
unhide_progress()
Unhide output window progress bar.
unlock_size()
Unock window size.
update_progress(cur_value, max_value)
Activate and update the output window progress bar.
Parameters
• cur_value (float) – current progress value e.g. 50
• max_value (float) – total value e.g. 100
Example
8.1. [Link] 91
pyRevit Documentation, Release 4.8.12.22247+0031
window
Return output window object.
Type [Link]
[Link].docclosing_eventhandler(sender, args)
Close all output window on document closing.
[Link].get_default_stylesheet()
Return default css stylesheet used by output window.
[Link].get_output()
[Link] : Return output window.
[Link].get_stylesheet()
Return active css stylesheet used by output window.
[Link].reset_stylesheet()
Reset active stylesheet to default.
[Link].set_stylesheet(stylesheet)
Set active css stylesheet used by output window.
Parameters stylesheet (str) – full path to stylesheet file
[Link].setup_output_closer()
Setup document closing event listener.
92 Chapter 8. [Link]
CHAPTER 9
[Link]
9.1 [Link]
9.2 [Link]
93
pyRevit Documentation, Release 4.8.12.22247+0031
[Link].convert_point_to_metric(rvt_point)
Convert given point coordinates to metric.
9.3 [Link]
Example
>>> get_model_sync_history("//servername/path/to/[Link]")
... [SyncHistory(index=498, userid="user",
... timestamp="2017-12-13 19:56:20")]
[Link].get_server_path(doc, path_dict)
Return file path of a model hosted on revit server.
Parameters
• doc (Document) – revit document object
• path_dict (dict) – dict of RSN paths and their directory paths
94 Chapter 9. [Link]
pyRevit Documentation, Release 4.8.12.22247+0031
Example
9.4 [Link]
9.4. [Link] 95
pyRevit Documentation, Release 4.8.12.22247+0031
Example
get_swallowed_errors()
Return swallowed errors
on_failure_processing(_, event_args)
Failure processing event handler
reset()
Reset swallowed errors
class [Link]
static close_doc(doc)
Close given document.
Parameters doc ([Link]) – document
static open_doc(doc_path)
Open document at given path.
Parameters doc_path (str) – document file path
Returns opened document
Return type [Link]
static post_command(command_id)
Request Revit to run a command
Parameters command_id (str) – command identifier e.g.
ID_REVIT_SAVE_AS_TEMPLATE
96 Chapter 9. [Link]
CHAPTER 10
[Link]
10.1 [Link]
10.1.1 [Link]
97
pyRevit Documentation, Release 4.8.12.22247+0031
add_header(key, value)
Add new header key:value
callback_url
Request callback url, if provided in payload
headers
Request headers dict
params
Request parameters
class [Link](status=200, data=None, headers=None)
Response wrapper object
add_header(key, value)
Add new header key:value
headers
Response headers dict
[Link]()
Initialize routes. Reset all registered routes and shutdown servers
[Link].activate_server()
Activate routes server for this host instance
[Link].deactivate_server()
Deactivate the active routes server for this host instance
[Link].get_active_server()
Get active routes server for this host instance
[Link].make_response(data, status=200, headers=None)
Create Reponse object with
[Link].get_routes(api_name)
Get all registered routes for given API name
Parameters api_name (str) – unique name of the api
[Link].add_route(api_name, pattern, method, handler_func)
Add new route for given API name
Parameters
• api_name (str) – unique name of the api
• pattern (str) – route pattern
• method (str) – method name
• handler_func (function) – route handler function
[Link].remove_route(api_name, pattern, method)
Remove previously registered route for given API name
Parameters
• api_name (str) – unique name of the api
• pattern (str) – route pattern
• method (str) – method name
HTTP API framework similar to flask.
class [Link](name)
API root object
Parameters name (str) – URL-safe unique root name of the API
Example
route(pattern, methods=[’GET’])
Define a new route on this API.
[Link].active_routes_api()
Activates routes API
10.1. [Link] 99
pyRevit Documentation, Release 4.8.12.22247+0031
[Link]
Example
[Link].clipboard_copy(string_to_copy)
Copy string to Windows Clipboard.
[Link].data_exists(slot_name, this_project=True)
Checks if data file in a specified slot and for certain project exists.
Parameters
• slot_name (type) – desc
• this_project (bool) – data belongs to this project only
Returns true if the path exists
Return type bool
[Link].dump_csv(data, filepath)
Dumps given data into given csv file.
Parameters
• data (list[list[str]]) – data to be dumped
• filepath (str) – csv file path
[Link].dump_json(data, filepath)
Dumps given data into given json file.
101
pyRevit Documentation, Release 4.8.12.22247+0031
Parameters
• data (object) – serializable data to be dumped
• filepath (str) – json file path
[Link]()
Stop the script execution and exit.
[Link].get_all_buttons()
Find and return all ui buttons matching current script command name.
Sometimes tools are duplicated across extensions for user access control so this would help smart buttons to find
all the loaded buttons and make icon adjustments.
Returns list of ui button objects
Return type list([Link]._PyRevitRibbonButton)
[Link].get_alt_script_path()
Return config script path of the current pyRevit command.
Returns config script path
Return type str
[Link].get_bundle_file(file_name)
Return full path to file under current script bundle.
Parameters file_name (str) – bundle file name
Returns full bundle file path
Return type str
[Link].get_bundle_files(sub_path=None)
Return full path to all file under current script bundle.
Returns list of bundle file paths
Return type list[str]
[Link].get_bundle_name()
Return bundle name of the current pyRevit command.
Returns bundle name (e.g. [Link])
Return type str
[Link].get_button()
Find and return current script ui button.
Returns ui button object
Return type [Link]._PyRevitRibbonButton
[Link].get_config(section=None)
Create and return config section parser object for current script.
Parameters section (str, optional) – config section name
Returns Config section parser object
Return type [Link]
[Link].get_data_file(file_id, file_ext, add_cmd_name=False)
Return filename to be used by a user script to store data.
Example
Data files are not cleaned up at pyRevit startup. Script should manage cleaning up these files.
Parameters
• file_id (str) – unique id for the filename
• file_ext (str) – file extension
• add_cmd_name (bool, optional) – add command name to file name
Returns full file path
Return type str
[Link].get_document_data_file(file_id, file_ext, add_cmd_name=False)
Return filename to be used by a user script to store data.
File name is generated in this format: pyRevit_{Revit Version}_{file_id}_{Project Name}.
{file_ext}
Example
Document data files are not cleaned up at pyRevit startup. Script should manage cleaning up these files.
Parameters
• file_id (str) – unique id for the filename
• file_ext (str) – file extension
• add_cmd_name (bool, optional) – add command name to file name
Returns full file path
Return type str
[Link].get_envvar(envvar)
Return value of give pyRevit environment variable.
The environment variable system is used to retain small values in memory between script runs (e.g. ac-
tive/inactive state for toggle tools). Do not store large objects in memory using this method. List of currently
set environment variables could be sees in pyRevit settings window.
Parameters envvar (str) – name of environment variable
Returns type of object stored in environment variable
Return type any
103
pyRevit Documentation, Release 4.8.12.22247+0031
Example
>>> script.get_envvar('ToolActiveState')
True
[Link].get_extension_name()
Return extension name of the current pyRevit command.
Returns extension name (e.g. [Link])
Return type str
[Link].get_info()
Return info on current pyRevit command.
Returns Command info object
Return type [Link]
[Link].get_instance_data_file(file_id, add_cmd_name=False)
Return filename to be used by a user script to store data.
File name is generated in this format: pyRevit_{Revit Version}_{Process Id}_{file_id}.
{file_ext}
Example
>>> script.get_instance_data_file('mydata')
'.../pyRevit_2018_6684_mydata.tmp'
>>> script.get_instance_data_file('mydata', add_cmd_name=True)
'.../pyRevit_2018_6684_Command Name_mydata.tmp'
[Link].get_results()
Return command results dictionary for logging.
Returns Command results dict
Return type [Link]
[Link].get_script_path()
Return script path of the current pyRevit command.
Returns script path
Return type str
[Link].get_unique_id()
Return unique id of the current pyRevit command.
Returns command unique id
Return type str
[Link].get_universal_data_file(file_id, file_ext, add_cmd_name=False)
Return filename to be used by a user script to store data.
File name is generated in this format: pyRevit_{file_id}.{file_ext}
Example
Universal data files are not cleaned up at pyRevit startup. Script should manage cleaning up these files.
Parameters
• file_id (str) – unique id for the filename
• file_ext (str) – file extension
• add_cmd_name (bool, optional) – add command name to file name
Returns full file path
Return type str
[Link].journal_read(data_key)
Read value for provided key from active Revit journal.
Parameters data_key (str) – data key
Returns data value string
Return type str
[Link].journal_write(data_key, msg)
Write key and value to active Revit journal for current command.
Parameters
• data_key (str) – data key
• msg (str) – data value string
105
pyRevit Documentation, Release 4.8.12.22247+0031
[Link].load_csv(filepath)
Read lines from given csv file
Parameters filepath (str) – csv file path
Returns csv data
Return type list[list[str]]
[Link].load_data(slot_name, this_project=True)
Wraps python [Link]() to easily load data from pyRevit data files
To recover native Revit objects, use [Link](). See Example
Similar to pickle module, the custom data types must be defined in the main scope so the loader can create an
instance and return original stored data
Parameters
• slot_name (type) – desc
• this_project (bool) – data belongs to this project only
Returns stored data
Return type obj
Example
[Link].load_index(index_file=’[Link]’)
Load html file into output window.
This method expects [Link] file in the current command bundle, unless full path to an html file is provided.
Parameters index_file (str, optional) – full path of html file.
[Link].load_json(filepath)
Loads data from given json file.
Example
[Link].show_file_in_explorer(file_path)
Show file in Windows Explorer.
[Link].show_folder_in_explorer(folder_path)
Show folder in Windows Explorer.
[Link].store_data(slot_name, data, this_project=True)
Wraps python [Link]() to easily store data to pyRevit data files
To store native Revit objects, use [Link](). See Example
Parameters
• slot_name (type) – desc
• data (obj) – any pickalable data
• this_project (bool) – data belongs to this project only
107
pyRevit Documentation, Release 4.8.12.22247+0031
Example
[Link]
Handle reading and parsing, writin and saving of all user configurations.
This module handles the reading and writing of the pyRevit configuration files. It’s been used extensively by pyRevit
sub-modules. user_config is set up automatically in the global scope by this module and can be imported into
scripts and other modules to access the default configurations.
All other modules use this module to query user config.
Example
The user_config object is also the destination for reading and writing configuration by pyRevit scripts through
get_config() of [Link] module. Here is the function source:
def get_config(section=None):
"""Create and return config section parser object for current script.
Args:
section (str, optional): config section name
Returns:
:obj:`[Link]`:
Config section parser object
"""
from [Link] import user_config
if not section:
script_cfg_postfix = 'config'
section = EXEC_PARAMS.command_name + script_cfg_postfix
(continues on next page)
109
pyRevit Documentation, Release 4.8.12.22247+0031
try:
return user_config.get_section(section)
except Exception:
return user_config.add_section(section)
Example
Example
config_file
Current config file path.
get_active_cpython_engine()
Return active cpython engine.
get_config_version()
Return version of config file used for change detection.
get_current_attachment()
Return current pyRevit attachment.
get_ext_root_dirs()
Return a list of all extension directories.
Returns list of strings. user extension directories.
Return type list
get_ext_sources()
Return a list of extension definition source files
static get_list_separator()
Get list separator defined in user os regional settings.
get_thirdparty_ext_root_dirs(include_default=True)
Return a list of external extension directories set by the user.
111
pyRevit Documentation, Release 4.8.12.22247+0031
[Link]
13.1 [Link]
Example
113
pyRevit Documentation, Release 4.8.12.22247+0031
madein
Alias for field number 1
subtitle
Alias for field number 0
[Link].get_pyrevit_about()
Return information about pyRevit project.
Returns pyRevit project info tuple
Return type PyRevitAbout
13.2 [Link]
13.3 [Link]
[Link].upgrade_existing_pyrevit()
Upgrade existing pyRevit deployment.
[Link].upgrade_user_config(user_config)
Upgarde user configurations.
Parameters
• user_config ([Link]) – config object
• val (type) – desc
Utility functions for managing pyRevit versions.
Example
class [Link]._PyRevitVersion(signature)
pyRevit version wrapper.
Parameters commit_hash (str) – signature
as_int_tuple()
Returns version as an int tuple (major, minor, patch)
as_str_tuple()
Returns version as an string tuple (‘major’, ‘minor’, ‘patch’)
get_formatted(strict=False, extended=False)
Returns ‘[Link]’ in string
[Link].get_pyrevit_cli_version()
Return version of shipped pyRevit CLI utility.
Returns version string of pyRevit CLI utility binary
Return type str
[Link].get_pyrevit_repo()
Return pyRevit repository.
Returns repo wrapper object
Return type [Link]
[Link].get_pyrevit_version()
Return information about active pyRevit version.
Returns version wrapper object
Return type _PyRevitVersion
p [Link], 113
pyrevit, 3 [Link], 114
[Link], 9 [Link], 114
[Link], 11
[Link], 40
[Link], 13
[Link], 15
[Link], 17
[Link], 27
[Link], 28
[Link], 29
[Link], 31
[Link], 33
[Link], 33
[Link], 34
[Link], 36
[Link], 54
[Link], 53
[Link], 53
[Link], 79
[Link], 84
[Link], 81
[Link], 81
[Link], 83
[Link], 83
[Link], 84
[Link], 85
[Link], 85
[Link], 95
[Link], 93
[Link], 93
[Link], 94
[Link], 95
[Link], 98
[Link], 97
[Link], 97
[Link], 101
[Link], 109
[Link], 115
117
pyRevit Documentation, Release 4.8.12.22247+0031
119
pyRevit Documentation, Release 4.8.12.22247+0031
120 Index
pyRevit Documentation, Release 4.8.12.22247+0031
Index 121
pyRevit Documentation, Release 4.8.12.22247+0031
122 Index
pyRevit Documentation, Release 4.8.12.22247+0031
Index 123
pyRevit Documentation, Release 4.8.12.22247+0031
has_subsection() (pyre- 88
inspect_calling_scope_global_var() (in
[Link]
method), 28 module [Link]), 48
head_name ([Link] attribute), 30 inspect_calling_scope_local_var() (in
header ([Link] module [Link]), 48
attribute), 28 int2hex_long() (in module [Link]), 48
headers ([Link] attribute), is_api_object() (in module [Link]), 9
97 is_blank() (in module [Link]), 48
headers ([Link] at- is_box_visible_on_screens() (in module pyre-
tribute), 97 [Link]), 48
headers ([Link] attribute), 98 is_data_file_available() (in module pyre-
headers ([Link] attribute), 98 [Link]), 14
hex2int_long() (in module [Link]), 47 is_demo (pyrevit._HostApplication attribute), 4
hex_color ([Link] attribute), 17 is_dirty() ([Link]
hide() ([Link] method), method), 38
86 is_enabled_for() (pyre-
hide_element() ([Link] static [Link] method),
method), 62 32
hide_logpanel() (pyre- is_exactly() (pyrevit._HostApplication method), 4
[Link] method), is_file_available() (in module pyre-
86 [Link]), 15
hide_progress() (pyre- is_native() ([Link]
[Link] method), static method), 38
87 is_native() ([Link]
host_version (pyre- static method), 39
[Link] attribute), is_newer_than() (pyrevit._HostApplication
82 method), 4
is_older_than() (pyrevit._HostApplication
I method), 5
icon_file_path (pyre- is_product_demo() (in module [Link]), 9
[Link] attribute), is_pyrevit_data_file() (in module pyre-
36 [Link]), 15
id (pyrevit._HostAppPostableCommand attribute), 3 is_pyrevit_tab() (pyre-
increment_str() (in module [Link]), 47 [Link]
indeterminate ([Link] at- static method), 39
tribute), 57 is_registered_dockable_panel() (in module
indeterminate_progress() (pyre- [Link]), 69
[Link] method), is_url_valid() (in module [Link]), 48
87 isEnabledFor() (pyre-
index ([Link] attribute), [Link] method),
94 32
inform_wip() (in module [Link]), 69 isnumber() (in module [Link]), 34
init() (in module [Link]), 98 isreadonly ([Link] attribute), 56
inject_script() (pyre- istype ([Link] attribute), 56
[Link] method), itemdata_mode (pyre-
87 [Link]
inject_to_body() (pyre- attribute), 37
[Link] method),
87 J
inject_to_head() (pyre- join_strings() (in module [Link]), 48
[Link] method), journal_read() (in module [Link]), 105
87 journal_write() (in module [Link]), 105
insert_divider() (pyre-
[Link] method),
124 Index
pyRevit Documentation, Release 4.8.12.22247+0031
K make_bar_chart() (pyre-
key (pyrevit._HostAppPostableCommand attribute), 3 [Link] method),
kill_tasks() (in module [Link]), 49 88
make_bubble_chart() (pyre-
L [Link] method),
language (pyrevit._HostApplication attribute), 5 88
large_bitmap ([Link] make_canonical_name() (in module pyre-
attribute), 37 [Link]), 49
last_commit_hash ([Link] make_chart() ([Link]
attribute), 30 method), 88
linkify() ([Link] make_doughnut_chart() (pyre-
static method), 88 [Link] method),
list_data_files() (in module pyre- 88
[Link]), 15 make_line_chart() (pyre-
list_instance_data_files() (in module pyre- [Link] method),
[Link]), 15 88
load_bitmapimage() (in module pyre- make_link() (in module [Link]), 85
[Link]), 40 make_pie_chart() (pyre-
load_component() (in module [Link]), [Link] method),
54 88
load_csv() (in module [Link]), 105 make_polar_chart() (pyre-
load_ctrl_template() (in module pyre- [Link] method),
[Link]), 54 89
load_data() (in module [Link]), 106 make_radar_chart() (pyre-
load_index() (in module [Link]), 106 [Link] method),
load_itemspanel_template() (in module pyre- 89
[Link]), 54 make_response() (in module [Link]),
load_json() (in module [Link]), 106 98
load_session() (in module pyre- make_stacked_chart() (pyre-
[Link]), 83 [Link] method),
location ([Link] 89
attribute), 81 mark() (in module [Link]), 33
lock_size() ([Link] medium_bitmap ([Link]
method), 88 attribute), 37
log_debug() ([Link] merge() (in module [Link]), 35
method), 88
log_error() ([Link] N
method), 88 name (pyrevit._HostAppPostableCommand attribute), 3
log_info() ([Link] name ([Link] attribute), 17
method), 88 name ([Link] attribute), 30
log_success() (pyre- name ([Link]
[Link] method), attribute), 37
88 name ([Link] attribute), 56
log_warning() (pyre- name ([Link]
[Link] method), attribute), 81
88 needs_clean_engine (pyrevit._ExecutorParams at-
loggers_have_errors() (in module pyre- tribute), 8
[Link]), 32 needs_fullframe_engine (pyre-
LoggerWrapper (class in [Link]), 31 vit._ExecutorParams attribute), 8
luminance ([Link] attribute), 17 needs_persistent_engine (pyre-
vit._ExecutorParams attribute), 8
M needs_refreshed_engine (pyre-
madein ([Link] at- vit._ExecutorParams attribute), 8
tribute), 113
Index 125
pyRevit Documentation, Release 4.8.12.22247+0031
126 Index
pyRevit Documentation, Release 4.8.12.22247+0031
Index 127
pyRevit Documentation, Release 4.8.12.22247+0031
128 Index
pyRevit Documentation, Release 4.8.12.22247+0031
Index 129
pyRevit Documentation, Release 4.8.12.22247+0031
V
verify_configs() (in module [Link]),
111
verify_directory() (in module [Link]),
52
version (pyrevit._HostApplication attribute), 6
version_name (pyrevit._HostApplication attribute), 6
130 Index
The module 'pyrevit.coreutils.ribbon' supports UI activation through methods like activate(), which can be used on objects such as GenericPyRevitUIContainer, enhancing the ability to dynamically control the interface components in Revit's ribbon UI.
The `get_formatted()` method improves version management by providing a string representation of the version in the format 'major.minor.patch'. This human-readable format is essential for conveying version information succinctly and accurately to users and developers, facilitating communication and documentation.
The RGB values for 'brown1' are (255, 64, 64), and for 'brown4', they are (139, 35, 35). 'Brown1' is significantly lighter and more saturated with a higher presence of red, resulting in a vivid appearance. 'Brown4' is darker with reduced saturation, presenting a more muted and deeper tone.
The RGB class is crucial in color management as it standardizes how colors are manipulated and displayed, providing a systematic way to define and compare colors numerically. In pyRevit, this class allows for precise color customization and visualization, critical for tasks requiring consistent color representation and manipulation.
The `random_hex_color()` method can be utilized in graphic design or UI development to generate random hex color values, promoting design variations and creativity in interfaces. It aids in quickly prototyping and visualizing diverse color schemes, thereby enhancing the aesthetic appeal and differentiation of design elements.
The module `pyrevit.revit.units` assists with unit handling by providing functions for converting and managing units within the Revit environment. A key method it offers for unit conversion is `project_to_world()`, which translates project units to world units, essential for accurate measurement and representation in a global context.
pyRevit version management addresses leftover temporary files by using a cleanup function, `remove_leftover_temp_files()`, that removes temp files with the extension ..bak. This function serves to resolve an issue in version 4.8.5 where such temporary files would be inappropriately created.
The primary function of the `pyrevit.forms` module is to manage and simplify user interactions through various dialog boxes and input mechanisms. The method `ask_for_color()` enhances user interaction by allowing users to select a color via a user-friendly dialog box, thereby facilitating intuitive user input.
The RGB values for 'blueviolet' are (138, 43, 226), while the standard 'blue' is represented by (0, 0, 255). 'Blueviolet' has a significant presence of red and green along with blue, giving it a purplish hue, compared to the pure blue hue of 'blue', which lacks any red or green.
The _PyRevitVersion class is a version wrapper in pyRevit's version management system that provides structured handling of version information. The method as_int_tuple() is significant as it allows the version to be represented as an integer tuple (major, minor, patch), facilitating numerical comparisons and version management automation processes.