Pyrevit
Pyrevit
Release 4.7.0-beta
eirannejad
4 Effective Output/Input 19
4.1 Clickable Element Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.2 Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.3 Code Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.4 Progress bars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.5 Standard Prompts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.6 Standard Dialogs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.7 Base Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.8 Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
5 Keyboard Shortcuts 45
5.1 Shift-Click: Alternate/Config Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.2 Ctrl-Click: Debug Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.3 Alt-Click: Show Script file in Explorer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
5.4 Ctrl-Shift-Alt-Click: Reload Engine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
5.5 Shift-Win-Click: pyRevit Button Context Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
7 pyRevit Configuration 55
i
8 Usage Logger 57
12 pyrevit 65
13 pyrevit.api 71
14 pyrevit.compat 73
15 pyrevit.coreutils 75
15.1 pyrevit.coreutils . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
15.2 pyrevit.coreutils.appdata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
15.3 pyrevit.coreutils.charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
15.4 pyrevit.coreutils.colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
15.5 pyrevit.coreutils.configparser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
15.6 pyrevit.coreutils.dotnetcompiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
15.7 pyrevit.coreutils.envvars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
15.8 pyrevit.coreutils.git . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
15.9 pyrevit.coreutils.loadertypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
15.10 pyrevit.coreutils.logger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
15.11 pyrevit.coreutils.mathnet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
15.12 pyrevit.coreutils.moduleutils . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
15.13 pyrevit.coreutils.pyutils . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
15.14 pyrevit.coreutils.ribbon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
16 pyrevit.forms 115
16.1 pyrevit.forms.toaster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
16.2 pyrevit.forms.utils . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
17 pyrevit.framework 135
18 pyrevit.loader 137
18.1 pyrevit.loader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
18.2 pyrevit.loader.asmmaker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
18.3 pyrevit.loader.sessioninfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
18.4 pyrevit.loader.systemdiag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
18.5 pyrevit.loader.sessionmgr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
18.6 pyrevit.loader.uimaker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
19 pyrevit.output 141
19.1 pyrevit.output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
19.2 pyrevit.output.linkmaker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
20 pyrevit.revit 149
20.1 pyrevit.revit.files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
20.2 pyrevit.revit.geom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
20.3 pyrevit.revit.serverutils . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
20.4 pyrevit.revit.units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
ii
21 pyrevit.script 153
22 pyrevit.userconfig 159
23 pyrevit.versionmgr 163
23.1 pyrevit.versionmgr.about . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
23.2 pyrevit.versionmgr.updater . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
23.3 pyrevit.versionmgr.upgrade . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
iii
iv
pyRevit Documentation, Release 4.7.0-beta
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.
• How To Use This Documents
• Create Your First Command
• Anatomy of a pyRevit Script
• Effective Output/Input
• Keyboard Shortcuts
• Extensions and Commmands
• pyRevit Configuration
• Usage Logger
• pyRevit CLI Utility
Getting Started 1
pyRevit Documentation, Release 4.7.0-beta
2 Getting Started
CHAPTER 1
3
pyRevit Documentation, Release 4.7.0-beta
5
pyRevit Documentation, Release 4.7.0-beta
pyRevit provides a few basic services to python scripts that use its engine. These fuctionalities are accessible through
a few high level modules. This article is a quick look at these services and their associated python modules.
pyRevit looks for certain global scope variables in each scripts that provide metadata about the script and follow the
__<name>__ format.
3.1.1 __title__
Button Title: When using the bundle name as the button name in Revit UI is not desired, or you want to add a
newline character to the command name to better display the butonn name inside Revit UI Panel, you can define the
__title__ variable in your script and set it to the desired button title.
__title__ = 'Sample\\nCommand'
7
pyRevit Documentation, Release 4.7.0-beta
3.1.2 __doc__
Button Tooltip: Tooltips are displayed similar to the other buttons in Revit interface. You can define the tooltip for a
script using the doscstring at the top of the script or by explicitly defining __doc__ metadata variable.
3.1.3 __author__
Script Author: You can define the script author as shown below. This will show up on the button tooltip.
3.1.4 __helpurl__
3.1.5 __min_revit_ver__
3.1.6 __max_revit_ver__
3.1.7 __beta__
Script In Beta: xx
3.1.8 __context__
Command Availability: Revit commands use standard IExternalCommandAvailability class to let Revit
know if they are available in different contexts. For example, if a command needs to work on a set of elements, it can
tell Revit to deactivate the button unless the user has selected one or more elements.
In pyRevit, command availability is set through the __context__ variable. Currently, pyRevit support three types
of command availability types.
# Tool activates when at least one element is selected
__context__ = 'Selection'
# Tools are active even when there are no documents available/open in Revit
__context__ = 'zerodoc'
# Tool activates when all selected elements are of the given category or categories
__context__ = '<Element Category>'
__context__ = ['<Element Category>', '<Element Category>']
<Element Category> can be any of the standard Revit element categories. See Appendix B: System Category
Names for a full list of system categories. You can use the List tool under pyRevit > Spy and list the standard
categories.
Here are a few examples:
# Tool activates when all selected elements are of the given category
__context__ = 'Doors'
__context__ = 'Walls'
__context__ = 'Floors'
__context__ = ['Space Tags', 'Spaces']
All pyRevit scripts should use the pyrevit.script module to access pyRevit functionality unless listed otherwise.
pyRevit internals are subject to changes and accessing them directly is not suggested.
Here is a list of supported modules for pyRevit scripts. Examples of using the functionality in these modules are
provided on this page.
pyrevit.script
This module provides access to output window (pyrevit.output), logging (pyrevit.
coreutils.logger), temporary files (pyrevit.coreutils.appdata), and other misc fea-
tures. See the module page for usage examples and full documentation of all available functions.
3.2.1 Logging
You can get the default logger for the script using pyrevit.script.get_logger().
from pyrevt import script
logger = script.get_logger()
Critical and warning messages are printed in color for clarity. Normally debug messages are not printed. you can hold
CTRL and click on a command button to put that command in DEBUG mode and see all its debug messages
output = script.get_output()
output.set_height(600)
output.get_title()
output.set_title('More control please!')
Each script can save and load configuration pyRevit’s user configuration file:
See pyrevit.output for more examples.
See pyrevit.script.get_config() and pyrevit.script.save_config() for the individual func-
tions used here.
config = script.get_config()
# saving configurations
script.save_config()
pyRevit has a usage logging system that can record all tool usages to either a json file or to a web server. Scripts can
return custom data to this logging system.
In example below, the script reports the amount of time it saved to the logging system:
results = script.get_results()
results.timesaved = 10
• Data files
These files are marked by host Revit version and could be shared between instances of host Revit
version Data files are saved in pyRevit’s appdata directory and are NOT cleaned up when Revit
restarts.
See pyrevit.script.get_data_file()
(Shared only between instances of host Revit version): These files are marked by host Revit version
and name of Active Project and could be shared between instances of host Revit version. Data files
are saved in pyRevit’s appdata directory and are NOT cleaned up when Revit restarts.
See pyrevit.script.get_document_data_file()
# You can also pass a document object to get a data file for that
# document (use document name in file naming)
script.get_document_data_file(file_id, file_ext, doc)
Note: It’s strongly advised not to read or write values from these variables unless necessary. The pyrevit module
provides wrappers around these variables that are safe to use.
# results dictionary
__result__
Adaptive Points
Air Terminal Tags
Air Terminals
Analysis Display Style
Analysis Results
Analytical Beam Tags
Analytical Beams
Analytical Brace Tags
Analytical Braces
Analytical Column Tags
Analytical Columns
Analytical Floor Tags
Analytical Floors
Analytical Foundation Slabs
Analytical Isolated Foundation Tags
Analytical Isolated Foundations
Analytical Link Tags
Analytical Links
Analytical Node Tags
Analytical Nodes
Analytical Slab Foundation Tags
Analytical Spaces
Analytical Surfaces
Analytical Wall Foundation Tags
Analytical Wall Foundations
Analytical Wall Tags
Analytical Walls
Annotation Crop Boundary
Area Load Tags
Area Tags
Areas
Assemblies
Assembly Tags
Boundary Conditions
Brace in Plan View Symbols
Cable Tray Fitting Tags
Cable Tray Fittings
Cable Tray Runs
Cable Tray Tags
Cable Trays
Callout Boundary
Callout Heads
Callouts
Cameras
Casework
(continues on next page)
Effective Output/Input
work in progress
19
pyRevit Documentation, Release 4.7.0-beta
4.2 Tables
work in progress
work in progress
work in progress
4.5.1 Alerts
Example
Example
Example
A more advanced example of combining command options, on/off switches, and option or switch configuration
options:
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”
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:
Example
Example
pyrevit.forms.pick_folder(title=None)
Show standard windows pick folder dialog.
Parameters title (str, optional) – title for the window
Returns folder path
Return type str
Example
Example
Example
Example
Example
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.
Example
Example
4.8 Graphs
Step 1: Create a chart object for the chart type that you want. We’ll add data to this later. . .
output = script.get_output()
# Line chart
chart = output.make_line_chart()
# Bar chart
chart = output.make_bar_chart()
# Bubble chart
chart = output.make_bubble_chart()
# Radar chart
chart = output.make_radar_chart()
# Polar chart
chart = output.make_polar_chart()
# Pie chart
chart = output.make_pie_chart()
# Doughnut chart
chart = output.make_doughnut_chart()
Step 1-a: Optional: Setup the chart title, and other options. the full list of options for every chart is available on
Charts.js Documentation page. Some of the properties have their own sub-properties, for example the title option
for the charts has multiple sub-properties as shown below. The value for these type of properties should be a dictionary
of the sub-properties you’d like to set. All this is explained clearly in the Charts.js Documentation
chart.set_style('height:150px')
4.8. Graphs 37
pyRevit Documentation, Release 4.7.0-beta
Step 2: Now let’s add data to the chart. Every chart object has a data property chart.data that we can interact
with to add datasets to the chart. Different types of charts need different types of data sets in terms of how data is
organized, so the chart can present multiple data sets correctly. I’m providing two examples here, one for a simple line
chart (showing 3 different data sets) and another for a radial chart (also showing 3 different data sets within the same
chart). They’re all very similar to each other though.
Step 3: The last step is to ask the chart object to draw itself.
4.8. Graphs 39
pyRevit Documentation, Release 4.7.0-beta
set_b = chart.data.new_dataset('set_b')
set_b.data = [50, 30, 80]
set_b.backgroundColor = ["#913175", "#70A3C4", "#FFC057"]
set_c = chart.data.new_dataset('set_c')
set_c.data = [40, 20, 10]
set_c.backgroundColor = ["#DD5B82", "#E7E8F5", "#FFE084"]
4.8. Graphs 41
pyRevit Documentation, Release 4.7.0-beta
4.8. Graphs 43
pyRevit Documentation, Release 4.7.0-beta
Here is a little info on how the charts engine works: the pyRevit charts module is pyrevit.coreutils.charts.
This is the module that the output window interacts with to create the charts.
The charts module provides the chart object and handles the creation of datasets. The first thing it does when drawing
the graph is to create a html <canvas> element and assign a unique id to it:
<canvas id="chart123456"></canvas>
Then it parses the input data and creates a JSON representation of the data. The JSON string (json_data) will be
inserted into a template javascript. This javascript creates a Chart object from the Chart.js library:
and finally, the pyRevit chart object, injects this dynamically created javascript into the <head> of the output window
WebBrowser component:
output.inject_script(js_code)
Keyboard Shortcuts
if __shiftclick__:
do_task_A()
else:
do_task_B()
CTRL-clicking on a ui button will run the script in DEBUG mode and will allow the script to print all debug messages.
You can check the value of __forceddebugmode__ variable to see if the script is running in Debug mode to change
script behaviour if neccessary.
if __forceddebugmode__:
do_task_A()
else:
do_task_B()
45
pyRevit Documentation, Release 4.7.0-beta
ALT-clicking on a ui button will show the associated script file in windows explorer.
If you’re using pyRevit Rocket mode, this keyboard combination will force pyRevit to discard the cached engine for
this command and use a new fresh engine. If you are developing scripts for pyRevit and using external modules, you’ll
need to use this keyboard combination after changes to the imported module source codes. Since the modules are
already imported in the cached engine, you’d need a new fresh engine to reload the modules.
Shows the context menu for the pyRevit command. See image below:
pyRevit’s extensions system has evolved again to be more flexible and easier to work with. We’ll dive right into how
you can add your own extension, but first let’s answer one important question:
Q: Why would I need to create a separate extension? Why Can’t I just add my scripts to the current pyRevit tools?
A: Because pyRevit is a git repository and the real benefit of that is that you can keep it always updated without the
need to unsinstall and install the newer versions. To keep this system running without issues, I highly recommend
not to mess with the pyRevit git repository folders and contents and pyRevit makes it really easy to add your own
extensions. You can even add tools to the standard pyRevit tab in your own extensions. I’ll show you how.
Besides, by creating a separate extension, you’ll have all your precious scripts and tools in a safe place and away from
the changes being made to the core pyRevit. They can even live somewhere on your company shared drives and be
shared between your teams.
6.2 Extensions
Each extension is a group of tools, organized in bundles to be easily accessible through the user interface.
Extensions are organized in a folder bundle with .extension postfix.
Like this one:
47
pyRevit Documentation, Release 4.7.0-beta
There are two steps that you need to follow to create your own extensions:
• Setup external extension folder:
First, is to create a separate folder for all your custom extensions and tell pyRevit to load your
extensions from this folder. This is done in the Settings window, under the Custom Extension folders
section. This way your precious extensions will stay out of the pyRevit installation and are safe.
The most basic bundle is a command bundle. There are more than one type of command bundles but a .pushbutton
bundle explained here covers 90% of the use cases.
And this is a more advanced command bundle with a configuration script and configuration window definition file:
Now that we have explained the command bundles, we need a way to organize these commands into a user-friendly
interface. Let’s introduce Group Bundles
A group bundle is a bundle that can contain command bundles and other group bundles. They come in all different
shapes and sizes but they have a few features in common:
• They can contain command bundles and other group bundles. (But I’ve already said that)
PushButton A
PushButton B
PullDown A
---
PullDown B
Stack3 A
>>>
PushButton C
PullDown C
This bundle creates a Tab in the Ribbon with the bundle name.
This bundle creates a Panel in a Ribbon Tab with the bundle name.
This bundle creates a Pulldown Button in a Ribbon Panel or a Stack, with the bundle name and icon.
This bundle creates a Split Button button in a Ribbon Panel or a Stack, with the bundle name and icon.
This bundle creates a Split Push Button button (The sticky split button) in a Ribbon Panel or a Stack, with the bundle
name and icon.
There are a few more advanced bundle types in pyRevit as well. Here is some quick intro on these bundles.
Example
pyRevit.smartbutton
Smart buttons are python scripts that are written like modules. They should define __selfinit__ function as
shown below. This function gets executed at startup time to give a chance to the button to initialize itself (e.g set its
icon based on its state).
The __selfinit__ must return True if the initialization is successful and False if it is not. pyRevit will not
create the button if the initialization returns False and is unsuccessful.
Returns:
bool: Return True if successful, False if not
"""
run_self_initialization()
Example
pyRevit.nobutton
No-Button bundles are just like Pushbutton bundles except that they will never show up inside Revit UI and thus don’t
need any icons. The only method to run these commands is through pyRevit Search tool. These commands are meant
for more advanced commands that not every user needs.
Example
pyRevit.panelbutton
Panle Button bundles are just like Pushbutton bundles except that they will be set as the panel configuration button
(small arrow at the corner of UI Panels). These bundles do not need to have an icon as the standard Small arrow icon
is used for panel configuration buttons by default. These commands work just like any pyRevit command but their
primary purpose should be to configure set of related tools in a panel.
Example
pyRevit.linkbutton
Link buttons can call a function from another Addin. To make a link button define the parameters below in the bundles
script.py:
Note: For this button to work properly, the target addin must be already loaded when this button is being created,
otherwise Revit can not tie the UI button to an assembly that is not loaded.
For example to call the Interactive Python Shell from RevitPythonShell addin:
__assembly__ = 'RevitPythonShell'
__commandclass__ = 'IronPythonConsoleCommand'
Library extensions are created to share IronPython modules between all extensions. They’re in essence IronPython
module packages. Some users might decide to develop an IronPython library (e.g. RevitPythonWrapper Library) that
other users can use in their tools and benefit from.
Library extensions are identified by .lib postfix. The library extension folder address will be added to the sys.
path of all the other extensions by the loader.
pyRevit Configuration
work in progress
55
pyRevit Documentation, Release 4.7.0-beta
Usage Logger
work in progress
57
pyRevit Documentation, Release 4.7.0-beta
pyRevit has a command line utility tool that helps managing pRevit clones, extensions and configurations, a lot easier.
Documentation The documentation for this tool is provided in a markdown file inside the pyrevit repository. The
reason is that the cli tool knows the link to its own help based on its versions, to the markdown file on the repo, and
can direct the user to it upon running pyrevit help. It made more sense to maintain the help in a single file inside
the repo, rather than a more complex documentation like this that needs sphinx to generate the actual documentation
pages.
You can access the latest CLI help HERE
pyRevit Core
• Load Sequence, Step 1: Revit Addon
• Load Sequence, Step 2: IronPython Module
59
pyRevit Documentation, Release 4.7.0-beta
Here is the full source of pyRevitLoader.py. The docstring explains how it works.
61
pyRevit Documentation, Release 4.7.0-beta
This is the starting point for pyRevit. At Revit loads the PyRevitLoader.dll
addon at startup. This dll then creates an ironpython engine and runs
pyRevitLoader.py (this script). It's the job of this script to setup the
environment for the pyrevit module (pyrevitlib\pyrevit) and load a new pyRevit
session. This script needs to add the directory path of the pyrevit lib folder
so the pyrevit module can be imported and used.
"""
import sys
import os.path as op
work in progress
pyRevit Module
• pyrevit
• pyrevit.api
• pyrevit.compat
• pyrevit.coreutils
• pyrevit.forms
• pyrevit.framework
• pyrevit.loader
• pyrevit.output
• pyrevit.revit
• pyrevit.script
• pyrevit.userconfig
• pyrevit.versionmgr
63
pyRevit Documentation, Release 4.7.0-beta
pyrevit
Examples
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
65
pyRevit Documentation, Release 4.7.0-beta
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 docu-
ment and ui-document, available postable commands, and other functionality.
Parameters host_uiapp (UIApplication) – Instance of running host.
Example
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
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.
67
pyRevit Documentation, Release 4.7.0-beta
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
69
pyRevit Documentation, Release 4.7.0-beta
pyrevit.api
Example
71
pyRevit Documentation, Release 4.7.0-beta
pyrevit.compat
Example
73
pyRevit Documentation, Release 4.7.0-beta
pyrevit.coreutils
15.1 pyrevit.coreutils
Example
class pyrevit.coreutils.FileWatcher(filepath)
Bases: object
Simple file version watcher.
This is a simple utility class to look for changes in a file based on its timestamp.
Example
has_changed
Compare current file timestamp to the cached timestamp.
update_tstamp()
Update the cached timestamp for later comparison.
75
pyRevit Documentation, Release 4.7.0-beta
class pyrevit.coreutils.SafeDict
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 pyrevit.coreutils.ScriptFileParser(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_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
get_docstring()
Get global docstring.
class pyrevit.coreutils.Timer
Bases: object
Timer class using python native time module.
Example
get_time()
Get Elapsed Time.
restart()
Restart Timer.
pyrevit.coreutils.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
pyrevit.coreutils.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
pyrevit.coreutils.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.
pyrevit.coreutils.check_revittxt_encoding(filename)
Check if given file is in UTF-16 (UCS-2 LE) encoding.
Parameters filename (str) – file path
pyrevit.coreutils.check_utf8bom_encoding(filename)
Check if given file is in UTF-8 encoding.
Parameters filename (str) – file path
pyrevit.coreutils.cleanup_filename(file_name)
Cleanup file name from special characters.
Parameters file_name (str) – file name
Returns cleaned up file name
Return type str
15.1. pyrevit.coreutils 77
pyRevit Documentation, Release 4.7.0-beta
Example
>>> cleanup_filename('Myfile-(3).txt')
"Myfile(3).txt"
pyrevit.coreutils.cleanup_string(input_str)
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
pyrevit.coreutils.correct_revittxt_encoding(filename)
Convert encoding of text file generated by Revit to UTF-8.
Parameters filename (str) – file path
pyrevit.coreutils.create_ext_command_attrs()
Create dotnet attributes for Revit extenrnal commads.
This method is used in creating custom dotnet types for pyRevit commands and compiling them into a
DLL assembly. Current implementation sets RegenerationOption.Manual and TransactionMode.
Manual
Returns list of CustomAttributeBuilder for RegenerationOption and
TransactionMode attributes.
Return type list
pyrevit.coreutils.create_type(modulebuilder, type_class, class_name, custom_attr_list, *args)
Create a dotnet type for a pyRevit command.
See baseclasses.cs code for the template pyRevit command dotnet type and its constructor default argu-
ments that must be provided here.
Parameters
• modulebuilder (ModuleBuilder) – dotnet module builder
• type_class (type) – source dotnet type for the command
• class_name (str) – name for the new type
• custom_attr_list (list) – list of dotnet attributes for the type
• *args – list of arguments to be used with type constructor
Returns returns created dotnet type
Return type type
Example
pyrevit.coreutils.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'
pyrevit.coreutils.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'
pyrevit.coreutils.decrement_str(input_str, step)
Decrement identifier.
Parameters
• input_str (str) – identifier e.g. A310a
• step (int) – number of steps to change the identifier
Returns modified identifier
Return type str
15.1. pyrevit.coreutils 79
pyRevit Documentation, Release 4.7.0-beta
Example
>>> decrement_str('A310a')
'A309z'
pyrevit.coreutils.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
pyrevit.coreutils.extract_guid(source_str)
Extract GUID number from a string.
pyrevit.coreutils.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']
pyrevit.coreutils.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
pyrevit.coreutils.find_loaded_asm(asm_info, by_partial_name=False, by_location=False)
Find loaded assembly based on name, partial name, or location.
Parameters
• asm_info (str) – name or location of the assembly
Example
>>> get_canonical_parts("Config.SubConfig")
['Config', 'SubConfig']
15.1. pyrevit.coreutils 81
pyRevit Documentation, Release 4.7.0-beta
pyrevit.coreutils.get_enum_none(enum_type)
Returns the None value in given Enum.
pyrevit.coreutils.get_enum_value(enum_type, value_string)
Return enum value matching given value string (case insensitive)
pyrevit.coreutils.get_enum_values(enum_type)
Returns enum values.
pyrevit.coreutils.get_exe_version(exepath)
Extract Product Version value from EXE file.
pyrevit.coreutils.get_file_name(file_path)
Return file basename of the given file.
Parameters file_path (str) – file path
pyrevit.coreutils.get_mapped_drives_dict()
Return a dictionary of currently mapped network drives.
pyrevit.coreutils.get_reg_key(key, subkey)
Get value of the given Windows registry key and subkey.
Parameters
• key (PyHKEY) – parent registry key
• subkey (str) – subkey path
Returns registry key if found, None if not found
Return type PyHKEY
Example
pyrevit.coreutils.get_revit_instance_count()
Return number of open host app instances.
Returns number of open host app instances.
Return type int
pyrevit.coreutils.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
pyrevit.coreutils.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
pyrevit.coreutils.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
pyrevit.coreutils.increment_str(input_str, step)
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
Example
>>> increment_str('A319z')
'A320a'
pyrevit.coreutils.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
pyrevit.coreutils.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
pyrevit.coreutils.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
15.1. pyrevit.coreutils 83
pyRevit Documentation, Release 4.7.0-beta
Example
>>> is_url_valid('https://www.google.com')
True
pyrevit.coreutils.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
Returns joined string
Return type str
pyrevit.coreutils.kill_tasks(task_name)
Kill running tasks matching task_name
Parameters task_name (str) – task name
Example
>>> kill_tasks('Revit.exe')
pyrevit.coreutils.load_asm(asm_name)
Load assembly by name into current domain.
Parameters asm_name (str) – assembly name
Returns returns the loaded assembly, None if not loaded.
pyrevit.coreutils.load_asm_file(asm_file)
Load assembly by file into current domain.
Parameters asm_file (str) – assembly file path
Returns returns the loaded assembly, None if not loaded.
pyrevit.coreutils.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
pyrevit.coreutils.new_uuid()
Create a new UUID (using dotnet Guid.NewGuid)
pyrevit.coreutils.open_folder_in_explorer(folder_path)
Open given folder in Windows Explorer.
Parameters folder_path (str) – directory path
pyrevit.coreutils.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 ditinquishes between <> printed from python and <> that define html.
Parameters input_string (str) – input html string
Example
pyrevit.coreutils.random_alpha()
Return a random alpha value (between 0 and 1.00).
pyrevit.coreutils.random_color()
Return a random color channel value (between 0 and 255).
pyrevit.coreutils.random_hex_color()
Return a random color in hex format.
Example
>>> random_hex_color()
'#FF0000'
pyrevit.coreutils.random_rgb_color()
Return a random color in rgb format.
Example
>>> random_rgb_color()
'rgb(255, 0, 0)'
pyrevit.coreutils.random_rgba_color()
Return a random color in rgba format.
Example
>>> random_rgba_color()
'rgba(255, 0, 0, 0.5)'
15.1. pyrevit.coreutils 85
pyRevit Documentation, Release 4.7.0-beta
pyrevit.coreutils.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
pyrevit.coreutils.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
Example
pyrevit.coreutils.reverse_dict(input_dict)
Reverse the key, value pairs.
Parameters input_dict (dict) – source ordered dict
Returns reversed dictionary
Return type defaultdict
Example
pyrevit.coreutils.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 ditinquishes between <> printed from python and <> that define html.
Parameters input_html (str) – input codified html string
Example
pyrevit.coreutils.run_process(proc, cwd=’C:’)
Run shell process silently.
Parameters
• proc (str) – process executive name
• cwd (str) – current working directory
Exmaple:
pyrevit.coreutils.show_entry_in_explorer(entry_path)
Show given entry in Windows Explorer.
Parameters entry_path (str) – directory or file path
pyrevit.coreutils.timestamp()
Return timestamp for current time.
Returns timestamp in string format
Return type str
Example
>>> timestamp()
'01003075032506808'
pyrevit.coreutils.touch(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
pyrevit.coreutils.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
15.1. pyrevit.coreutils 87
pyRevit Documentation, Release 4.7.0-beta
pyrevit.coreutils.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.
15.2 pyrevit.coreutils.appdata
Example
pyrevit.coreutils.appdata.cleanup_appdata_folder()
Cleanup appdata folder of all temporary appdata files.
pyrevit.coreutils.appdata.garbage_data_file(file_path)
Mark and remove the given appdata file.
Current implementation removes the file immediately.
Parameters file_path (str) – path to the target file
pyrevit.coreutils.appdata.get_data_file(file_id, file_ext, name_only=False)
Get path to file that will not be cleaned up at Revit load.
e.g pyrevit_2016_eirannejad_file_id.file_ext
Parameters
• file_id (str) – Unique identifier for the file
• file_ext (str) – File extension
• name_only (bool) – If true, function returns file name only
Returns File name or full file path (depending on name_only)
Return type str
pyrevit.coreutils.appdata.get_instance_data_file(file_id, file_ext=’tmp’,
name_only=False)
Get path to file that should be used by current instance only.
These data files will be cleaned up at Revit restart. e.g pyrevit_2016_eirannejad_2353_file_id.file_ext
Parameters
• file_id (str) – Unique identifier for the file
• file_ext (str) – File extension
15.2. pyrevit.coreutils.appdata 89
pyRevit Documentation, Release 4.7.0-beta
15.3 pyrevit.coreutils.charts
Example
>>> chart.set_style('height:150px')
set_width(width)
Set chart width on output window.
class pyrevit.coreutils.charts.PyRevitOutputChartData
Bases: object
Chart data wrapper object.
new_dataset(dataset_label)
Create new data set.
Parameters dataset_label (str) – dataset label
Example
>>> chart.data.new_dataset('set_a')
class pyrevit.coreutils.charts.PyRevitOutputChartDataset(label)
Bases: object
Chart dataset wrapper object.
set_color(*args)
Set dataset color.
Arguments are expected to be R, G, B, A values.
Example
class pyrevit.coreutils.charts.PyRevitOutputChartOptions
Bases: object
Chart options wrapper object.
15.4 pyrevit.coreutils.colors
Provide RGB color constants and a colors dictionary with elements formatted: COLORS[colorname] = CONSTANT
Example
15.4. pyrevit.coreutils.colors 91
pyRevit Documentation, Release 4.7.0-beta
Type int
blue
value for blue component (0-255)
Type int
hex_color
Return color in hex format
luminance
Return color luminance (preceived)
safe_text_color
Return text color that is safe to overlap this color.
# 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)
ANTIQUEWHITE3 = RGB(name='antiquewhite3', red=205, green=192, blue=176)
ANTIQUEWHITE4 = RGB(name='antiquewhite4', red=139, green=131, blue=120)
AQUA = RGB(name='aqua', red=0, green=255, blue=255)
AQUAMARINE1 = RGB(name='aquamarine1', red=127, green=255, blue=212)
AQUAMARINE2 = RGB(name='aquamarine2', red=118, green=238, blue=198)
AQUAMARINE3 = RGB(name='aquamarine3', red=102, green=205, blue=170)
AQUAMARINE4 = RGB(name='aquamarine4', red=69, green=139, blue=116)
AZURE1 = RGB(name='azure1', red=240, green=255, blue=255)
AZURE2 = RGB(name='azure2', red=224, green=238, blue=238)
AZURE3 = RGB(name='azure3', red=193, green=205, blue=205)
AZURE4 = RGB(name='azure4', red=131, green=139, blue=139)
BANANA = RGB(name='banana', red=227, green=207, blue=87)
BEIGE = RGB(name='beige', red=245, green=245, blue=220)
BISQUE1 = RGB(name='bisque1', red=255, green=228, blue=196)
BISQUE2 = RGB(name='bisque2', red=238, green=213, blue=183)
BISQUE3 = RGB(name='bisque3', red=205, green=183, blue=158)
BISQUE4 = RGB(name='bisque4', red=139, green=125, blue=107)
BLACK = RGB(name='black', red=0, green=0, blue=0)
BLANCHEDALMOND = RGB(name='blanchedalmond', red=255, green=235, blue=205)
BLUE = RGB(name='blue', red=0, green=0, blue=255)
BLUE2 = RGB(name='blue2', red=0, green=0, blue=238)
BLUE3 = RGB(name='blue3', red=0, green=0, blue=205)
BLUE4 = RGB(name='blue4', red=0, green=0, blue=139)
BLUEVIOLET = RGB(name='blueviolet', red=138, green=43, blue=226)
BRICK = RGB(name='brick', red=156, green=102, blue=31)
BROWN = RGB(name='brown', red=165, green=42, blue=42)
BROWN1 = RGB(name='brown1', red=255, green=64, blue=64)
BROWN2 = RGB(name='brown2', red=238, green=59, blue=59)
BROWN3 = RGB(name='brown3', red=205, green=51, blue=51)
BROWN4 = RGB(name='brown4', red=139, green=35, blue=35)
BURLYWOOD = RGB(name='burlywood', red=222, green=184, blue=135)
BURLYWOOD1 = RGB(name='burlywood1', red=255, green=211, blue=155)
BURLYWOOD2 = RGB(name='burlywood2', red=238, green=197, blue=145)
BURLYWOOD3 = RGB(name='burlywood3', red=205, green=170, blue=125)
BURLYWOOD4 = RGB(name='burlywood4', red=139, green=115, blue=85)
(continues on next page)
15.4. pyrevit.coreutils.colors 93
pyRevit Documentation, Release 4.7.0-beta
15.4. pyrevit.coreutils.colors 95
pyRevit Documentation, Release 4.7.0-beta
15.4. pyrevit.coreutils.colors 97
pyRevit Documentation, Release 4.7.0-beta
15.4. pyrevit.coreutils.colors 99
pyRevit Documentation, Release 4.7.0-beta
15.5 pyrevit.coreutils.configparser
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. Section.SubSection
15.6 pyrevit.coreutils.dotnetcompiler
15.7 pyrevit.coreutils.envvars
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}
pyrevit.coreutils.envvars.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
pyrevit.coreutils.envvars.get_pyrevit_env_vars()
Get the root dictionary, holding all environment variables.
pyrevit.coreutils.envvars.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
15.8 pyrevit.coreutils.git
head_name
head branch name
Type str
last_commit_hash
hash of head commit
Type str
repo
LibGit2Sharp.Repository object
Type str
branch
current branch name
Type str
username
credentials - username
Type str
password
credentials - password
Type str
pyrevit.coreutils.git.compare_branch_heads(repo_info)
Compare local and remote branch heads and return ???
Parameters repo_info (RepoInfo) – target repo object
Returns desc
Return type type
pyrevit.coreutils.git.get_all_new_commits(repo_info)
Fetch and return new commits ahead of current head.
Parameters repo_info (RepoInfo) – target repo object
Returns str]: ordered dict of commit hash:message
Return type OrderedDict[str
pyrevit.coreutils.git.get_repo(repo_dir)
Return repo object for given git repo directory.
Parameters repo_dir (str) – full path of git repo directory
Returns repo object
Return type RepoInfo
pyrevit.coreutils.git.git_clone(repo_url, clone_dir, username=None, password=None)
Clone git repository to given location
Parameters
• repo_url (str) – repo .git url
• clone_dir (str) – destination path
• username (str) – credentials - username
15.9 pyrevit.coreutils.loadertypes
15.10 pyrevit.coreutils.logger
has_errors()
Check if logger has reported any errors.
isEnabledFor(level)
Override logging.Logger.isEnabledFor
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.
pyrevit.coreutils.logger.get_file_hndlr()
Return file logging handler object.
Returns configured instance of python’s native stream handler
Return type logging.FileHandler
pyrevit.coreutils.logger.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
pyrevit.coreutils.logger.get_stdout_hndlr()
Return stdout logging handler object.
Returns configured instance of python’s native stream handler
Return type logging.StreamHandler
pyrevit.coreutils.logger.loggers_have_errors()
Check if any errors have been reported by any of registered loggers.
pyrevit.coreutils.logger.set_file_logging(status)
Set file logging status (enable/disable).
15.11 pyrevit.coreutils.mathnet
Example
15.12 pyrevit.coreutils.moduleutils
15.13 pyrevit.coreutils.pyutils
Example
Example
copy()
Copy the dictionary.
pyrevit.coreutils.pyutils.compare_lists(x, y)
Compare two lists.
See: https://stackoverflow.com/a/10872313/2350244
Parameters
• x (list) – first list
• y (list) – second list
pyrevit.coreutils.pyutils.isnumber(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
pyrevit.coreutils.pyutils.pairwise(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
Example
15.14 pyrevit.coreutils.ribbon
large_bitmap
Resamples image and creates bitmap for size ICON_LARGE.
Returns object containing image data at given size
Return type Imaging.BitmapSource
medium_bitmap
Resamples image and creates bitmap for size ICON_MEDIUM.
Returns object containing image data at given size
Return type Imaging.BitmapSource
small_bitmap
Resamples image and creates bitmap for size ICON_SMALL.
Returns object containing image data at given size
Return type Imaging.BitmapSource
class pyrevit.coreutils.ribbon.GenericPyRevitUIContainer
Bases: object
Common type for all pyRevit ui containers.
name
container name
Type str
itemdata_mode
if container is wrapping UI.*ItemData
Type bool
activate()
Activate this container in ui.
contains(pyrvt_cmp_name)
Check if container contains a component with given name.
Parameters
• pyrvt_cmp_name (str) – target component name
• val (type) – desc
deactivate()
Deactivate this container in ui.
enabled
Is container enabled.
find_child(child_name)
Find a component with given name in children.
Parameters child_name (str) – target component name
Returns component object if found, otherwise None
Return type
•
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.
class pyrevit.coreutils.ribbon.GenericRevitNativeUIContainer
Bases: pyrevit.coreutils.ribbon.GenericPyRevitUIContainer
Example
pyrevit.coreutils.ribbon.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
pyrevit.coreutils.ribbon.load_bitmapimage(image_file)
Load given png file.
Parameters image_file (str) – image file path
Returns bitmap image object
Return type Imaging.BitmapImage
pyrevit.forms
Example
Example
115
pyRevit Documentation, Release 4.7.0-beta
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 pyrevit.forms.GetValueWindow(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.
class pyrevit.forms.ParamDef(name, istype)
Parameter definition tuple.
name
parameter name
Type str
istype
true if type parameter, otherwise false
Type bool
istype
Alias for field number 1
name
Alias for field number 0
class pyrevit.forms.ProgressBar(height=32, **kwargs)
Show progress bar at the top of Revit window.
Parameters
• title (string) – progress bar text, defaults to 0/100 progress format
• indeterminate (bool) – create indeterminate progress bar
• cancellable (bool) – add cancel button to progress bar
• step (int) – update progress intervals
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”
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.
117
pyRevit Documentation, Release 4.7.0-beta
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
wait_async(func, args=())
Call a method asynchronosely and show progress.
class pyrevit.forms.RevisionOption(revision_element)
Revision wrapper for select_revisions().
name
Revision name (description).
class pyrevit.forms.SearchPrompt(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
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 pyrevit.forms.SelectFromList(context, title, width, height, **kwargs)
Standard form to select from a list of items.
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
119
pyRevit Documentation, Release 4.7.0-beta
• 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.
• group_selector_title (str) – title for list group selector. defaults to ‘List Group’
• default_group (str) – name of defautl group to be selected
Example
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.
>>> from pyrevit import forms
>>> class MyOption(forms.TemplateListItem)
... @property
... def name(self):
... return '{} - {}{}'.format(self.item.SheetNumber,
... self.item.SheetNumber)
>>> ops = [MyOption('op1'), MyOption('op2', True), MyOption('op3')]
>>> res = forms.SelectFromList.show(ops,
... multiselect=True,
... button_name='Select Item')
>>> [bool(x) for x in res] # or [x.state for x in res]
[True, False, True]
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.
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.
class pyrevit.forms.SheetOption(sheet_element)
Sheet wrapper for select_sheets().
name
Sheet name.
number
Sheet number.
class pyrevit.forms.TemplateListItem(orig_item, checkable=True, name_attr=None)
Base class for checkbox option wrapping another object.
checkable
List Item CheckBox Visibility.
classmethod is_checkbox(item)
Check if the object has all necessary attribs for a checkbox.
name
Name property.
unwrap()
Unwrap and return wrapped object.
class pyrevit.forms.TemplatePromptBar(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()
update_window()
Update the prompt bar to match Revit window.
class pyrevit.forms.TemplateUserInputWindow(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
121
pyRevit Documentation, Release 4.7.0-beta
Example
static disable_element(*wpf_elements)
Enable elements.
Parameters *wpf_elements – WPF framework elements to be enabled
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_image_source(wpf_element, image_file)
Set source file for image element.
Parameters
• element_name (System.Windows.Controls.Image) – 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 pyrevit.forms.WarningBar(height=32, **kwargs)
Show warning bar at the top of Revit window.
Parameters title (string) – warning bar text
Example
123
pyRevit Documentation, Release 4.7.0-beta
Example
Example
Example
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'
Example
125
pyRevit Documentation, Release 4.7.0-beta
>>> 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=self.Title,
... reserved_values=['Ehsan', 'Gui', 'Guido'],
... owner=self)
... 'unique string'
Example
Example
>>> forms.inform_wip()
pyrevit.forms.pick_excel_file(save=False)
File pick/save dialog for an excel file.
Parameters save (bool) – show file save dialog, instead of file pick dialog
Returns file path
Return type str
pyrevit.forms.pick_file(file_ext=”, files_filter=”, init_dir=”, restore_dir=True, multi_file=False,
unc_paths=False)
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
Returns file path or list of file paths if multi_file=True
Return type str or list[str]
127
pyRevit Documentation, Release 4.7.0-beta
Example
pyrevit.forms.pick_folder(title=None)
Show standard windows pick folder dialog.
Parameters title (str, optional) – title for the window
Returns folder path
Return type str
pyrevit.forms.save_excel_file()
File save dialog for an excel file.
Returns file path
Return type str
pyrevit.forms.save_file(file_ext=”, files_filter=”, init_dir=”, default_name=”, restore_dir=True,
unc_paths=False)
Save file dialog to select a destination file for data.
Parameters
• file_ext (str) – file extension
• files_filter (str) – file filter
• init_dir (str) – initial directory
• default_name (str) – default file name
• restore_dir (bool) – restore last directory
• unc_paths (bool) – return unc paths
Returns file path
Return type str
Example
Parameters
• images (list[str] | list[framework.Imaging.BitmapImage]) – list of
image file paths or bitmaps
• title (str, optional) – swatch list window title
• button_name (str, optional) – swatch list window button caption
Returns path of the selected image
Return type str
Example
Example
129
pyRevit Documentation, Release 4.7.0-beta
Example
>>> forms.select_parameter(
... src_element,
... title='Select Parameters',
... multiple=True,
... include_instance=True,
... include_type=True
... )
... [<ParamDef >, <ParamDef >]
Example
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.
• doc (DB.Document, optional) – source document for sheets; defaults to active doc-
ument
Returns list of selected sheets
Return type list[DB.ViewSheet]
Example
Example
131
pyRevit Documentation, Release 4.7.0-beta
Example
Example
Example
Example
16.1 pyrevit.forms.toaster
16.2 pyrevit.forms.utils
pyrevit.framework
Example
pyrevit.framework.get_dll_file(assembly_name)
Return path to given assembly name.
pyrevit.framework.get_type(fw_object)
Return CLR type of an object.
135
pyRevit Documentation, Release 4.7.0-beta
pyrevit.loader
18.1 pyrevit.loader
18.2 pyrevit.loader.asmmaker
location
Alias for field number 1
name
Alias for field number 0
reloading
Alias for field number 2
pyrevit.loader.asmmaker.create_assembly(extension)
Parameters extension (pyrevit.extensions.components.Extension) –
Returns:
18.3 pyrevit.loader.sessioninfo
137
pyRevit Documentation, Release 4.7.0-beta
Example
>>> sessioninfo.get_runtime_info()
pyrevit.loader.sessioninfo.get_session_uuid()
Read session uuid from environment variable.
Returns session uuid string
Return type str
pyrevit.loader.sessioninfo.get_total_loaded_assm_count()
Returns the total number of pyRevit assemblies loaded under current Revit session. This value is stored in an
environment variable and is kept updated during the multiple pyRevit sessions. Notice that not all of these
assemblies belong to current pyRevit session as pyRevit could be reloaded multiple times under the same Revit
session.
Returns Total number of loaded assemblies.
Return type int
pyrevit.loader.sessioninfo.new_session_uuid()
Create a new uuid for a pyRevit session.
Returns session uuid string
Return type str
pyrevit.loader.sessioninfo.report_env()
Report python version, home directory, config file, etc.
pyrevit.loader.sessioninfo.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
pyrevit.loader.sessioninfo.set_session_uuid(uuid_str)
Set session uuid on environment variable.
Parameters uuid_str (str) – session uuid string
pyrevit.loader.sessioninfo.set_total_loaded_assm_count(assm_count)
Sets the total number of pyRevit assemblies loaded under current Revit session. This value is stored in an
environment variable and is kept updated during the multiple pyRevit sessions.
This value should not be updated by pyRevit users.
Parameters assm_count (int) – assembly count
pyrevit.loader.sessioninfo.setup_runtime_vars()
Setup runtime environment variables with session information.
18.4 pyrevit.loader.systemdiag
Session diagnostics.
pyrevit.loader.systemdiag.system_diag()
Verifies system status is appropriate for a pyRevit session.
18.5 pyrevit.loader.sessionmgr
The loader module manages the workflow of loading a new pyRevit session. It’s main purpose is to orchestrate
the process of finding pyRevit extensions, creating dll assemblies for them, and creating a user interface in the host
application.
Everything starts from sessionmgr.load_session() function. . .
The only public function is load_session() that loads a new session. Everything else is private.
class pyrevit.loader.sessionmgr.AssembledExtension(ext, assm)
assm
Alias for field number 1
ext
Alias for field number 0
pyrevit.loader.sessionmgr.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
Example
pyrevit.loader.sessionmgr.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
Example
Returns None
18.6 pyrevit.loader.uimaker
UI maker.
pyrevit.loader.uimaker.update_pyrevit_ui(ui_ext, ext_asm_info, create_beta=False)
Updates/Creates pyRevit ui for the given extension and provided assembly dll address.
pyrevit.output
19.1 pyrevit.output
Example
Here is the source of pyrevit.script.get_output(). As you can see this functions calls the pyrevit.
output.get_output() to receive the output wrapper.
def get_output():
"""Return object wrapping output window for current script.
Returns:
:obj:`pyrevit.output.PyRevitOutputWindow`: Output wrapper object
"""
return output.get_output()
class pyrevit.output.PyRevitOutputWindow
Wrapper to interact with the output window.
add_style(style_code, attribs=None)
Inject style tag into current html head of the output window.
141
pyRevit Documentation, Release 4.7.0-beta
Parameters
• style_code (str) – css styling code
• attribs (dict) – dictionary of attribute names and value
Example
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.
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
insert_divider()
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_error(message)
Report ERROR message into output logging panel.
log_info(message)
Report INFO message into output logging panel.
log_ok(message)
Report OK message into output logging panel.
log_warning(message)
Report WARNING message into output logging panel.
make_bar_chart()
PyRevitOutputChart: Return bar chart object.
make_bubble_chart()
PyRevitOutputChart: Return bubble chart object.
make_chart()
PyRevitOutputChart: Return chart object.
make_doughnut_chart()
PyRevitOutputChart: Return dougnut chart object.
make_line_chart()
PyRevitOutputChart: Return line chart object.
make_pie_chart()
PyRevitOutputChart: Return pie chart object.
make_polar_chart()
PyRevitOutputChart: Return polar chart object.
make_radar_chart()
PyRevitOutputChart: Return radar chart object.
make_stacked_chart()
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
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 System.Windows.Forms.WebBrowser (In current implementation)
reset_icon()
Sets icon on the output window.
reset_progress()
Reset output window progress bar to zero.
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
window
Return output window object.
Type PyRevitBaseClasses.ScriptOutput
pyrevit.output.docclosing_eventhandler(sender, args)
Close all output window on document closing.
pyrevit.output.get_default_stylesheet()
Return default css stylesheet used by output window.
pyrevit.output.get_output()
pyrevit.output.PyRevitOutputWindow : Return output window.
pyrevit.output.get_stylesheet()
Return active css stylesheet used by output window.
pyrevit.output.reset_stylesheet()
Reset active stylesheet to default.
pyrevit.output.set_stylesheet(stylesheet)
Set active css stylesheet used by output window.
Parameters stylesheet (str) – full path to stylesheet file
pyrevit.output.setup_output_closer()
Setup document closing event listener.
19.2 pyrevit.output.linkmaker
pyrevit.output.linkmaker.make_link(element_ids, contents=None)
Create link for given element ids.
This link is a special format link with revit:// scheme that is handled by the output window to select the provided
element ids in current project. Scripts should not call this function directly. Creating clickable element links is
handled by the output wrapper object through the linkify() method.
Example
pyrevit.revit
20.1 pyrevit.revit.files
20.2 pyrevit.revit.geom
149
pyRevit Documentation, Release 4.7.0-beta
20.3 pyrevit.revit.serverutils
Example
>>> get_model_sync_history("//servername/path/to/model.rvt")
... [SyncHistory(index=498, userid="user",
... timestamp="2017-12-13 19:56:20")]
pyrevit.revit.serverutils.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
Example
20.4 pyrevit.revit.units
pyrevit.script
Example
pyrevit.script.clipboard_copy(string_to_copy)
Copy string to Windows Clipboard.
pyrevit.script.exit()
Stop the script execution and exit.
pyrevit.script.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(pyrevit.coreutils.ribbon._PyRevitRibbonButton)
pyrevit.script.get_alt_script_path()
Return alternate script path of the current pyRevit command.
Returns alternate script path
Return type str
pyrevit.script.get_bundle_file(file_name)
Return full path to file under current script bundle.
153
pyRevit Documentation, Release 4.7.0-beta
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
pyrevit.script.get_document_data_file(file_id, file_ext, add_cmd_name=False)
Return filename to be used by a user script to store data.
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
pyrevit.script.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
Example
>>> script.get_envvar('ToolActiveState')
True
pyrevit.script.get_extension_name()
Return extension name of the current pyRevit command.
Returns extension name (e.g. MyExtension.extension)
Return type str
pyrevit.script.get_info()
Return info on current pyRevit command.
Returns Command info object
Return type pyrevit.extensions.genericcomps.GenericUICommand
pyrevit.script.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}
155
pyRevit Documentation, Release 4.7.0-beta
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'
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
pyrevit.script.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
pyrevit.script.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
pyrevit.script.load_index(index_file=’index.html’)
Load html file into output window.
This method expects index.html 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.
pyrevit.script.open_url(url)
Open url in a new tab in default webbrowser.
pyrevit.script.reset_config(section=None)
Reset pyRevit config.
Script should call this to reset any save configuration by removing section related to current script.
Parameters section (str, optional) – config section name
pyrevit.script.save_config()
Save pyRevit config.
Scripts should call this to save any changes they have done to their config section object received from
script.get_config() method.
pyrevit.script.set_envvar(envvar, value)
Set value of give pyRevit environment variable.
157
pyRevit Documentation, Release 4.7.0-beta
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
• value (any) – value of environment variable
Example
pyrevit.script.show_file_in_explorer(file_path)
Show file in Windows Explorer.
pyrevit.script.show_folder_in_explorer(folder_path)
Show folder in Windows Explorer.
pyrevit.script.toggle_icon(new_state, on_icon_path=None, off_icon_path=None)
Set the state of button icon (on or off).
This method expects on.png and off.png in command bundle for on and off icon states, unless full path of icon
states are provided.
Parameters
• new_state (bool) – state of the ui button icon.
• on_icon_path (str, optional) – full path of icon for on state. default=’on.png’
• off_icon_path (str, optional) – full path of icon for off state. default=’off.png’
pyrevit.userconfig
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 pyrevit.script 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:`pyrevit.coreutils.configparser.PyRevitConfigSectionParser`:
Config section parser object
"""
from pyrevit.userconfig import user_config
if not section:
script_cfg_postfix = 'config'
section = EXEC_PARAMS.command_name + script_cfg_postfix
(continues on next page)
159
pyRevit Documentation, Release 4.7.0-beta
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.
static 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
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.
Returns list of strings. External user extension directories.
161
pyRevit Documentation, Release 4.7.0-beta
pyrevit.versionmgr
Example
class pyrevit.versionmgr._PyRevitVersion(patch_number)
pyRevit version wrapper.
Parameters patch_number (str) – patch value
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(nopatch=False)
Returns ‘major.minor:patch’ in string
pyrevit.versionmgr.get_pyrevit_cli_version()
Return version of shipped pyRevit CLI utility.
Returns version string of pyRevit CLI utility binary
Return type str
pyrevit.versionmgr.get_pyrevit_repo()
Return pyRevit repository.
Returns repo wrapper object
Return type pyrevit.coreutils.git.RepoInfo
163
pyRevit Documentation, Release 4.7.0-beta
pyrevit.versionmgr.get_pyrevit_version()
Return information about active pyRevit version.
Returns version wrapper object
Return type _PyRevitVersion
23.1 pyrevit.versionmgr.about
Example
23.2 pyrevit.versionmgr.updater
pyrevit.versionmgr.updater.check_for_updates()
Check whether any available repo has pending updates.
pyrevit.versionmgr.updater.get_all_extension_repos()
Return a list of repos for all installed extensions.
pyrevit.versionmgr.updater.get_thirdparty_ext_repos()
Return a list of repos for installed third-party extensions.
pyrevit.versionmgr.updater.get_updates(repo_info)
Fetch updates on repository.
Parameters repo_info (pyrevit.coreutils.git.RepoInfo) – repository info wrapper
object
pyrevit.versionmgr.updater.has_core_updates()
Check whether pyRevit repo has core updates.
This would require host application to be closed to release the file lock of core DLLs so they can be updated
separately.
pyrevit.versionmgr.updater.has_pending_updates(repo_info)
Check for updates on repository.
Parameters repo_info (pyrevit.coreutils.git.RepoInfo) – repository info wrapper
object
pyrevit.versionmgr.updater.update_pyrevit()
Update pyrevit and its extension repositories.
pyrevit.versionmgr.updater.update_repo(repo_info)
Update repository.
Parameters repo_info (pyrevit.coreutils.git.RepoInfo) – repository info wrapper
object
23.3 pyrevit.versionmgr.upgrade
p pyrevit.versionmgr.upgrade, 165
pyrevit, 65
pyrevit.api, 71
pyrevit.compat, 73
pyrevit.coreutils, 75
pyrevit.coreutils.appdata, 88
pyrevit.coreutils.charts, 90
pyrevit.coreutils.colors, 91
pyrevit.coreutils.configparser, 102
pyrevit.coreutils.dotnetcompiler, 103
pyrevit.coreutils.envvars, 103
pyrevit.coreutils.git, 104
pyrevit.coreutils.loadertypes, 106
pyrevit.coreutils.logger, 106
pyrevit.coreutils.mathnet, 108
pyrevit.coreutils.moduleutils, 108
pyrevit.coreutils.pyutils, 108
pyrevit.coreutils.ribbon, 110
pyrevit.forms, 115
pyrevit.forms.toaster, 133
pyrevit.forms.utils, 134
pyrevit.framework, 135
pyrevit.loader, 137
pyrevit.loader.asmmaker, 137
pyrevit.loader.sessioninfo, 137
pyrevit.loader.sessionmgr, 139
pyrevit.loader.systemdiag, 139
pyrevit.loader.uimaker, 140
pyrevit.output, 141
pyrevit.output.linkmaker, 147
pyrevit.revit.files, 149
pyrevit.revit.geom, 149
pyrevit.revit.serverutils, 150
pyrevit.revit.units, 151
pyrevit.script, 153
pyrevit.userconfig, 159
pyrevit.versionmgr, 163
pyrevit.versionmgr.about, 164
pyrevit.versionmgr.updater, 164
167
pyRevit Documentation, Release 4.7.0-beta
Symbols tribute), 66
_ExecutorParams (class in pyrevit), 67
_HostAppPostableCommand (class in pyrevit), 65
B
_HostApplication (class in pyrevit), 66 bitmap_from_file() (in module pyre-
_PyRevitVersion (class in pyrevit.versionmgr), 163 vit.forms.utils), 134
blue (pyrevit.coreutils.colors.RGB attribute), 92
A branch (pyrevit.coreutils.git.RepoInfo attribute), 105
build (pyrevit._HostApplication attribute), 66
activate() (pyrevit.coreutils.ribbon.GenericPyRevitUIContainer
button() (pyrevit.coreutils.ribbon.RevitNativeRibbonGroupItem
method), 111
method), 113
activate() (pyrevit.coreutils.ribbon.GenericRevitNativeUIContainer
button_select() (pyrevit.forms.SelectFromList
method), 113
method), 120
activeview (pyrevit._HostApplication attribute), 66
ButtonIcons (class in pyrevit.coreutils.ribbon), 110
add_section() (pyre-
vit.coreutils.configparser.PyRevitConfigParser C
method), 102
add_style() (pyrevit.output.PyRevitOutputWindow calculate_dir_hash() (in module pyre-
method), 141 vit.coreutils), 77
add_subsection() (pyre- callHandlers() (pyre-
vit.coreutils.configparser.PyRevitConfigSectionParser vit.coreutils.logger.LoggerWrapper method),
method), 102 106
alert() (in module pyrevit.forms), 123 can_access_url() (in module pyrevit.coreutils), 77
alert_ifnot() (in module pyrevit.forms), 124 chart_type (pyrevit.coreutils.charts.PyRevitOutputChart
app (pyrevit._HostApplication attribute), 66 attribute), 90
as_int_tuple() (pyre- check_all() (pyrevit.forms.SelectFromList method),
vit.versionmgr._PyRevitVersion method), 120
163 check_familydoc() (in module pyrevit.forms), 126
as_str_tuple() (pyre- check_for_updates() (in module pyre-
vit.versionmgr._PyRevitVersion method), vit.versionmgr.updater), 164
163 check_icon_size() (pyre-
ask_for_date() (in module pyrevit.forms), 124 vit.coreutils.ribbon.ButtonIcons method),
ask_for_one_item() (in module pyrevit.forms), 125 110
ask_for_string() (in module pyrevit.forms), 125 check_internet_connection() (in module pyre-
ask_for_unique_string() (in module pyre- vit.coreutils), 77
vit.forms), 126 check_revittxt_encoding() (in module pyre-
AssembledExtension (class in pyre- vit.coreutils), 77
vit.loader.sessionmgr), 139 check_selected() (pyrevit.forms.SelectFromList
assm (pyrevit.loader.sessionmgr.AssembledExtension at- method), 120
tribute), 139 check_selection() (in module pyrevit.forms), 126
available_servers (pyrevit._HostApplication at- check_utf8bom_encoding() (in module pyre-
vit.coreutils), 77
169
pyRevit Documentation, Release 4.7.0-beta
170 Index
pyRevit Documentation, Release 4.7.0-beta
138 vit.coreutils.appdata), 88
execute_command() (in module pyre- GenericPyRevitUIContainer (class in pyre-
vit.loader.sessionmgr), 139 vit.coreutils.ribbon), 111
execute_script() (in module pyre- GenericRevitNativeUIContainer (class in
vit.loader.sessionmgr), 139 pyrevit.coreutils.ribbon), 112
executed_from_ui (pyrevit._ExecutorParams get_active_cpython_engine() (pyre-
attribute), 68 vit.userconfig.PyRevitConfig method), 160
exit() (in module pyrevit.script), 153 get_adwindows_object() (pyre-
ext (pyrevit.loader.sessionmgr.AssembledExtension at- vit.coreutils.ribbon.GenericPyRevitUIContainer
tribute), 139 method), 111
ExtensionAssemblyInfo (class in pyre- get_all_buttons() (in module pyrevit.script), 153
vit.loader.asmmaker), 137 get_all_extension_repos() (in module pyre-
extract_guid() (in module pyrevit.coreutils), 80 vit.versionmgr.updater), 165
extract_param() (pyrevit.coreutils.ScriptFileParser get_all_new_commits() (in module pyre-
method), 76 vit.coreutils.git), 105
extract_range() (in module pyrevit.coreutils), 80 get_all_subclasses() (in module pyre-
vit.coreutils), 81
F get_alt_script_path() (in module pyre-
filestream (pyrevit.coreutils.ribbon.ButtonIcons at- vit.script), 153
tribute), 110 get_bundle_file() (in module pyrevit.script), 153
FileWatcher (class in pyrevit.coreutils), 75 get_bundle_files() (in module pyrevit.script), 154
filter_null_items() (in module pyre- get_bundle_name() (in module pyrevit.script), 154
vit.coreutils), 80 get_button() (in module pyrevit.script), 154
find_child() (pyre- get_canonical_parts() (in module pyre-
vit.coreutils.ribbon.GenericPyRevitUIContainer vit.coreutils), 81
method), 111 get_config() (in module pyrevit.script), 154
find_config_file() (in module pyre- get_config_file_hash() (pyre-
vit.userconfig), 161 vit.coreutils.configparser.PyRevitConfigParser
find_direct_match() (pyre- method), 102
vit.forms.SearchPrompt method), 118 get_config_version() (pyre-
find_loaded_asm() (in module pyrevit.coreutils), vit.userconfig.PyRevitConfig method), 160
80 get_current_attachment() (pyre-
find_pyrevitcmd() (in module pyre- vit.userconfig.PyRevitConfig static method),
vit.loader.sessionmgr), 140 160
find_type_by_name() (in module pyre- get_current_ui() (in module pyre-
vit.coreutils), 81 vit.coreutils.ribbon), 114
find_word_match() (pyrevit.forms.SearchPrompt get_data_file() (in module pyre-
method), 118 vit.coreutils.appdata), 88
first_load (pyrevit._ExecutorParams attribute), 68 get_data_file() (in module pyrevit.script), 154
forced_debug_mode (pyrevit._ExecutorParams at- get_default_stylesheet() (in module pyre-
tribute), 68 vit.output), 147
format() (pyrevit.coreutils.logger.DispatchingFormatter get_dll_file() (in module pyrevit.framework), 135
method), 106 get_docstring() (pyrevit.coreutils.ScriptFileParser
format_area() (in module pyrevit.revit.units), 151 method), 76
format_hex_rgb() (in module pyrevit.coreutils), 81 get_document_data_file() (in module pyre-
freeze() (pyrevit.output.PyRevitOutputWindow vit.script), 154
method), 142 get_enum_none() (in module pyrevit.coreutils), 81
fully_remove_dir() (in module pyrevit.coreutils), get_enum_value() (in module pyrevit.coreutils), 82
81 get_enum_values() (in module pyrevit.coreutils),
fuzzy_search_ratio() (in module pyre- 82
vit.coreutils), 81 get_envvar() (in module pyrevit.script), 155
get_exe_version() (in module pyrevit.coreutils),
G 82
garbage_data_file() (in module pyre- get_ext_root_dirs() (pyre-
Index 171
pyRevit Documentation, Release 4.7.0-beta
172 Index
pyRevit Documentation, Release 4.7.0-beta
Index 173
pyRevit Documentation, Release 4.7.0-beta
is_native() (pyrevit.coreutils.ribbon.GenericRevitNativeUIContainer
location (pyrevit.loader.asmmaker.ExtensionAssemblyInfo
static method), 113 attribute), 137
is_newer_than() (pyrevit._HostApplication lock_size() (pyrevit.output.PyRevitOutputWindow
method), 66 method), 144
is_older_than() (pyrevit._HostApplication log_error() (pyrevit.output.PyRevitOutputWindow
method), 66 method), 144
is_pyrevit_data_file() (in module pyre- log_info() (pyrevit.output.PyRevitOutputWindow
vit.coreutils.appdata), 89 method), 144
is_pyrevit_tab() (pyre- log_ok() (pyrevit.output.PyRevitOutputWindow
vit.coreutils.ribbon.RevitNativeRibbonTab method), 144
static method), 113 log_warning() (pyre-
is_url_valid() (in module pyrevit.coreutils), 83 vit.output.PyRevitOutputWindow method),
isEnabledFor() (pyre- 144
vit.coreutils.logger.LoggerWrapper method), loggers_have_errors() (in module pyre-
107 vit.coreutils.logger), 107
isnumber() (in module pyrevit.coreutils.pyutils), 109 LoggerWrapper (class in pyrevit.coreutils.logger),
istype (pyrevit.forms.ParamDef attribute), 116 106
itemdata_mode (pyre- luminance (pyrevit.coreutils.colors.RGB attribute), 92
vit.coreutils.ribbon.GenericPyRevitUIContainer
attribute), 111 M
madein (pyrevit.versionmgr.about.PyRevitAbout at-
J tribute), 164
join_strings() (in module pyrevit.coreutils), 84 make_bar_chart() (pyre-
journal_read() (in module pyrevit.script), 157 vit.output.PyRevitOutputWindow method),
journal_write() (in module pyrevit.script), 157 144
make_bubble_chart() (pyre-
K vit.output.PyRevitOutputWindow method),
key (pyrevit._HostAppPostableCommand attribute), 65 144
kill_tasks() (in module pyrevit.coreutils), 84 make_canonical_name() (in module pyre-
vit.coreutils), 84
L make_chart() (pyrevit.output.PyRevitOutputWindow
large_bitmap (pyrevit.coreutils.ribbon.ButtonIcons method), 144
attribute), 110 make_doughnut_chart() (pyre-
last_commit_hash (pyrevit.coreutils.git.RepoInfo vit.output.PyRevitOutputWindow method),
attribute), 105 144
linkify() (pyrevit.output.PyRevitOutputWindow make_line_chart() (pyre-
static method), 143 vit.output.PyRevitOutputWindow method),
list_data_files() (in module pyre- 144
vit.coreutils.appdata), 89 make_link() (in module pyrevit.output.linkmaker),
list_session_data_files() (in module pyre- 147
vit.coreutils.appdata), 90 make_pie_chart() (pyre-
load_asm() (in module pyrevit.coreutils), 84 vit.output.PyRevitOutputWindow method),
load_asm_file() (in module pyrevit.coreutils), 84 144
load_bitmapimage() (in module pyre- make_polar_chart() (pyre-
vit.coreutils.ribbon), 114 vit.output.PyRevitOutputWindow method),
load_component() (in module pyrevit.forms.utils), 144
134 make_radar_chart() (pyre-
load_ctrl_template() (in module pyre- vit.output.PyRevitOutputWindow method),
vit.forms.utils), 134 144
load_index() (in module pyrevit.script), 157 make_stacked_chart() (pyre-
load_itemspanel_template() (in module pyre- vit.output.PyRevitOutputWindow method),
vit.forms.utils), 134 144
load_session() (in module pyre- medium_bitmap (pyrevit.coreutils.ribbon.ButtonIcons
vit.loader.sessionmgr), 140 attribute), 111
174 Index
pyRevit Documentation, Release 4.7.0-beta
N print_table() (pyre-
name (pyrevit._HostAppPostableCommand attribute), 65 vit.output.PyRevitOutputWindow method),
name (pyrevit.coreutils.colors.RGB attribute), 91 145
name (pyrevit.coreutils.git.RepoInfo attribute), 104 proc (pyrevit._HostApplication attribute), 66
name (pyrevit.coreutils.ribbon.GenericPyRevitUIContainer proc_id (pyrevit._HostApplication attribute), 67
attribute), 111 proc_name (pyrevit._HostApplication attribute), 67
name (pyrevit.forms.ParamDef attribute), 116, 117 proc_path (pyrevit._HostApplication attribute), 67
name (pyrevit.forms.RevisionOption attribute), 118 proc_screen (pyrevit._HostApplication attribute), 67
name (pyrevit.forms.SheetOption attribute), 121 proc_screen_scalefactor (pyre-
name (pyrevit.forms.TemplateListItem attribute), 121 vit._HostApplication attribute), 67
name (pyrevit.forms.ViewOption attribute), 122 proc_screen_workarea (pyrevit._HostApplication
name (pyrevit.loader.asmmaker.ExtensionAssemblyInfo attribute), 67
attribute), 137 process_option() (pyre-
new_dataset() (pyre- vit.forms.CommandSwitchWindow method),
vit.coreutils.charts.PyRevitOutputChartData 116
method), 90 ProgressBar (class in pyrevit.forms), 117
new_session_uuid() (in module pyre- pyrevit (module), 65
vit.loader.sessioninfo), 138 pyrevit.api (module), 71
new_uuid() (in module pyrevit.coreutils), 84 pyrevit.compat (module), 73
next_page() (pyrevit.output.PyRevitOutputWindow pyrevit.coreutils (module), 75
method), 144 pyrevit.coreutils.appdata (module), 88
number (pyrevit.forms.SheetOption attribute), 121 pyrevit.coreutils.charts (module), 90
pyrevit.coreutils.colors (module), 91
O pyrevit.coreutils.configparser (module),
open_folder_in_explorer() (in module pyre- 102
vit.coreutils), 85 pyrevit.coreutils.dotnetcompiler (mod-
open_page() (pyrevit.output.PyRevitOutputWindow ule), 103
method), 144 pyrevit.coreutils.envvars (module), 103
open_url() (in module pyrevit.script), 157 pyrevit.coreutils.git (module), 104
open_url() (pyrevit.output.PyRevitOutputWindow pyrevit.coreutils.loadertypes (module),
method), 144 106
output (pyrevit.coreutils.charts.PyRevitOutputChart pyrevit.coreutils.logger (module), 106
attribute), 90 pyrevit.coreutils.mathnet (module), 108
output_id (pyrevit.output.PyRevitOutputWindow at- pyrevit.coreutils.moduleutils (module),
tribute), 144 108
output_uniqueid (pyre- pyrevit.coreutils.pyutils (module), 108
vit.output.PyRevitOutputWindow attribute), pyrevit.coreutils.ribbon (module), 110
145 pyrevit.forms (module), 115
pyrevit.forms.toaster (module), 133
P pyrevit.forms.utils (module), 134
pairwise() (in module pyrevit.coreutils.pyutils), 109 pyrevit.framework (module), 135
ParamDef (class in pyrevit.forms), 116 pyrevit.loader (module), 137
password (pyrevit.coreutils.git.RepoInfo attribute), 105 pyrevit.loader.asmmaker (module), 137
pick_excel_file() (in module pyrevit.forms), 127 pyrevit.loader.sessioninfo (module), 137
pick_file() (in module pyrevit.forms), 127 pyrevit.loader.sessionmgr (module), 139
pick_folder() (in module pyrevit.forms), 128 pyrevit.loader.systemdiag (module), 139
prepare_html_str() (in module pyrevit.coreutils), pyrevit.loader.uimaker (module), 140
85 pyrevit.output (module), 141
print_code() (pyrevit.output.PyRevitOutputWindow pyrevit.output.linkmaker (module), 147
static method), 145 pyrevit.revit.files (module), 149
print_html() (pyrevit.output.PyRevitOutputWindow pyrevit.revit.geom (module), 149
static method), 145 pyrevit.revit.serverutils (module), 150
print_md() (pyrevit.output.PyRevitOutputWindow pyrevit.revit.units (module), 151
static method), 145 pyrevit.script (module), 153
Index 175
pyRevit Documentation, Release 4.7.0-beta
176 Index
pyRevit Documentation, Release 4.7.0-beta
Index 177
pyRevit Documentation, Release 4.7.0-beta
178 Index
pyRevit Documentation, Release 4.7.0-beta
V
verify_configs() (in module pyrevit.userconfig),
161
verify_directory() (in module pyrevit.coreutils),
87
version (pyrevit._HostApplication attribute), 67
version_name (pyrevit._HostApplication attribute),
67
ViewOption (class in pyrevit.forms), 122
visible (pyrevit.coreutils.ribbon.GenericPyRevitUIContainer
attribute), 112
W
wait_async() (pyrevit.forms.ProgressBar method),
118
WarningBar (class in pyrevit.forms), 123
window (pyrevit.output.PyRevitOutputWindow at-
tribute), 147
window_handle (pyrevit._ExecutorParams attribute),
69
WPFWindow (class in pyrevit.forms), 122
Index 179