forms
pyrevit.forms facade.
Imports the engine-specific forms backend for the active Python engine.
Attributes
HOST_APP = _HostApplication()
module-attribute
EXEC_PARAMS = _ExecutorParams()
module-attribute
DOCS = _DocsGetter()
module-attribute
BIN_DIR = op.join(ROOT_BIN_DIR, DOTNET_RUNTIME_ID)
module-attribute
safe_strtype = str
module-attribute
user_config = PyRevitConfig(cfg_file_path=CONFIG_FILE, config_type=CONFIG_TYPE)
module-attribute
mlogger = get_logger(__name__)
module-attribute
DEFAULT_CMDSWITCHWND_WIDTH = 600
module-attribute
DEFAULT_SEARCHWND_WIDTH = 600
module-attribute
DEFAULT_SEARCHWND_HEIGHT = 100
module-attribute
DEFAULT_INPUTWINDOW_WIDTH = 500
module-attribute
DEFAULT_INPUTWINDOW_HEIGHT = 600
module-attribute
DEFAULT_RECOGNIZE_ACCESS_KEY = False
module-attribute
WPF_HIDDEN = framework.Windows.Visibility.Hidden
module-attribute
WPF_COLLAPSED = framework.Windows.Visibility.Collapsed
module-attribute
WPF_VISIBLE = framework.Windows.Visibility.Visible
module-attribute
XAML_FILES_DIR = op.dirname(__file__)
module-attribute
ParamDef = namedtuple('ParamDef', ['name', 'istype', 'definition', 'isreadonly', 'isunit', 'storagetype'])
module-attribute
Parameter definition tuple.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
parameter name |
istype |
bool
|
true if type parameter, otherwise false |
definition |
Definition
|
parameter definition object |
isreadonly |
bool
|
true if the parameter value can't be edited |
isunit |
bool
|
true if its ForgeTypeId is measurable |
storagetype |
Storagetype
|
String, Integer, Double or ElementId |
Classes
PyRevitException
Bases: Exception
Common base class for all pyRevit exceptions.
Parameters args and message are derived from Exception class.
Attributes
msg
property
Return exception message.
reactive(getter)
Bases: property
Decorator for WPF bound properties.
Source code in pyrevitlib/pyrevit/forms/_ipy.py
Functions
setter(setter)
Property setter.
Source code in pyrevitlib/pyrevit/forms/_ipy.py
Reactive
Bases: INotifyPropertyChanged
WPF property updator base mixin.
Functions
add_PropertyChanged(value)
remove_PropertyChanged(value)
OnPropertyChanged(prop_name)
Called when a property is changed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prop_name
|
str
|
property name |
required |
Source code in pyrevitlib/pyrevit/forms/_ipy.py
WindowToggler(window)
WPFPanel()
Bases: Page
WPF panel base class for all pyRevit dockable panels.
panel_id (str) must be set on the type to dockable panel uuid panel_source (str): xaml source filepath
Examples:
from pyrevit import forms
class MyPanel(forms.WPFPanel):
panel_id = "181e05a4-28f6-4311-8a9f-d2aa528c8755"
panel_source = "MyPanel.xaml"
forms.register_dockable_panel(MyPanel)
# then from the button that needs to open the panel
forms.open_dockable_panel("181e05a4-28f6-4311-8a9f-d2aa528c8755")
Initialize WPF panel and resources.
Source code in pyrevitlib/pyrevit/forms/_ipy.py
Attributes
panel_id = None
class-attribute
instance-attribute
panel_source = None
class-attribute
instance-attribute
thread_id = framework.get_current_thread_id()
instance-attribute
Functions
set_image_source(wpf_element, image_file)
Set source file for image element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wpf_element
|
Image
|
xaml image element |
required |
image_file
|
str
|
image file path |
required |
Source code in pyrevitlib/pyrevit/forms/_ipy.py
hide_element(*wpf_elements)
staticmethod
Collapse elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*wpf_elements
|
list[UIElement]
|
WPF framework elements to be collaped |
()
|
show_element(*wpf_elements)
staticmethod
Show collapsed elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*wpf_elements
|
list[UIElement]
|
WPF framework elements to be set to visible. |
()
|
toggle_element(*wpf_elements)
staticmethod
Toggle visibility of elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*wpf_elements
|
list[UIElement]
|
WPF framework elements to be toggled. |
()
|
disable_element(*wpf_elements)
staticmethod
Enable elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*wpf_elements
|
list[UIElement]
|
WPF framework elements to be enabled |
()
|
enable_element(*wpf_elements)
staticmethod
Enable elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*wpf_elements
|
list
|
WPF framework elements to be enabled |
()
|
handle_url_click(sender, args)
Callback for handling click on package website url.
TemplateListItem(orig_item, checked=False, checkable=True, name_attr=None)
Bases: Reactive
Base class for checkbox option wrapping another object.
Initialize the checkbox option and wrap given obj.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
orig_item
|
any
|
Object to wrap (must have name property or be convertable to string with str() |
required |
checked
|
bool
|
Initial state. Defaults to False |
False
|
checkable
|
bool
|
Use checkbox for items |
True
|
name_attr
|
str
|
Get this attribute of wrapped object as name |
None
|
Source code in pyrevitlib/pyrevit/forms/_ipy.py
Attributes
item = orig_item
instance-attribute
state = checked
instance-attribute
name
property
Name property.
checkable
property
writable
List Item CheckBox Visibility.
Functions
add_PropertyChanged(value)
remove_PropertyChanged(value)
OnPropertyChanged(prop_name)
Called when a property is changed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prop_name
|
str
|
property name |
required |
Source code in pyrevitlib/pyrevit/forms/_ipy.py
unwrap()
GetValueWindow(context, title, width, height, **kwargs)
Bases: TemplateUserInputWindow
Standard form to get simple values from user.
Examples:
from pyrevit import forms
items = ['item1', 'item2', 'item3']
forms.SelectFromList.show(items, button_name='Select Item')
['item1']
Initialize user input window.
Source code in pyrevitlib/pyrevit/forms/_ipy.py
Attributes
pyrevit_version
property
Active pyRevit formatted version e.g. '4.9-beta'.
default_title_key = 'pyRevit.DefaultWindowTitle'
class-attribute
instance-attribute
Title = title
instance-attribute
Width = width
instance-attribute
Height = height
instance-attribute
response = None
instance-attribute
Owner = owner
instance-attribute
WindowStartupLocation = framework.Windows.WindowStartupLocation.CenterOwner
instance-attribute
xaml_source = 'GetValueWindow.xaml'
class-attribute
instance-attribute
Functions
load_xaml(xaml_source, literal_string=False, handle_esc=True, set_owner=True)
Load the window XAML file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xaml_source
|
str
|
The XAML content or file path to load. |
required |
literal_string
|
bool
|
True if |
False
|
handle_esc
|
bool
|
Whether the ESC key should be handled. Defaults to True. |
True
|
set_owner
|
bool
|
Whether to se the window owner. Defaults to True. |
True
|
Source code in pyrevitlib/pyrevit/forms/_ipy.py
merge_resource_dict(xaml_source)
Merge a ResourceDictionary xaml file with this window.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xaml_source
|
str
|
xaml file with the resource dictionary |
required |
Source code in pyrevitlib/pyrevit/forms/_ipy.py
get_locale_string(string_name)
Get localized string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
string_name
|
str
|
string name |
required |
Returns:
| Type | Description |
|---|---|
str
|
localized string |
setup_owner()
setup_resources(wpf_ctrl)
staticmethod
Sets the WPF resources.
Source code in pyrevitlib/pyrevit/forms/_ipy.py
setup_default_handlers()
handle_input_key(sender, args)
set_icon(icon_path)
setup_icon()
hide()
show(context, title=None, width=DEFAULT_INPUTWINDOW_WIDTH, height=DEFAULT_INPUTWINDOW_HEIGHT, **kwargs)
classmethod
Show user input window.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
any
|
window context element(s) |
required |
title
|
str
|
window title |
None
|
width
|
int
|
window width |
DEFAULT_INPUTWINDOW_WIDTH
|
height
|
int
|
window height |
DEFAULT_INPUTWINDOW_HEIGHT
|
**kwargs
|
any
|
other arguments to be passed to window |
{}
|
Source code in pyrevitlib/pyrevit/forms/_ipy.py
show_dialog()
set_image_source_file(wpf_element, image_file)
staticmethod
Set source file for image element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wpf_element
|
Image
|
xaml image element |
required |
image_file
|
str
|
image file path |
required |
Source code in pyrevitlib/pyrevit/forms/_ipy.py
set_image_source(wpf_element, image_file)
Set source file for image element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wpf_element
|
Image
|
xaml image element |
required |
image_file
|
str
|
image file path |
required |
Source code in pyrevitlib/pyrevit/forms/_ipy.py
dispatch(func, *args, **kwargs)
Runs the function in a new thread.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable
|
function to run |
required |
*args
|
Any
|
positional arguments to pass to func |
()
|
**kwargs
|
Any
|
keyword arguments to pass to func |
{}
|
Source code in pyrevitlib/pyrevit/forms/_ipy.py
conceal()
hide_element(*wpf_elements)
staticmethod
Collapse elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*wpf_elements
|
list[UIElement]
|
WPF framework elements to be collaped |
()
|
show_element(*wpf_elements)
staticmethod
Show collapsed elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*wpf_elements
|
list[UIElement]
|
WPF framework elements to be set to visible. |
()
|
Source code in pyrevitlib/pyrevit/forms/_ipy.py
toggle_element(*wpf_elements)
staticmethod
Toggle visibility of elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*wpf_elements
|
list[UIElement]
|
WPF framework elements to be toggled. |
()
|
Source code in pyrevitlib/pyrevit/forms/_ipy.py
disable_element(*wpf_elements)
staticmethod
Enable elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*wpf_elements
|
list[UIElement]
|
WPF framework elements to be enabled |
()
|
enable_element(*wpf_elements)
staticmethod
Enable elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*wpf_elements
|
list[UIElement]
|
WPF framework elements to be enabled |
()
|
handle_url_click(sender, args)
Callback for handling click on package website url.
string_value_changed(sender, args)
Handle string vlaue update event.
Source code in pyrevitlib/pyrevit/forms/_ipy.py
select(sender, args)
Process input data and set the response.
Source code in pyrevitlib/pyrevit/forms/_ipy.py
TemplatePromptBar(height=32, **kwargs)
Bases: WPFWindow
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:
| Name | Type | Description | Default |
|---|---|---|---|
height
|
int
|
window height |
32
|
**kwargs
|
Any
|
other arguments to be passed to :func: |
{}
|
Initialize user prompt window.
Source code in pyrevitlib/pyrevit/forms/_ipy.py
Attributes
pyrevit_version
property
Active pyRevit formatted version e.g. '4.9-beta'.
xaml_source = 'TemplatePromptBar.xaml'
class-attribute
instance-attribute
user_height = height
instance-attribute
Functions
load_xaml(xaml_source, literal_string=False, handle_esc=True, set_owner=True)
Load the window XAML file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xaml_source
|
str
|
The XAML content or file path to load. |
required |
literal_string
|
bool
|
True if |
False
|
handle_esc
|
bool
|
Whether the ESC key should be handled. Defaults to True. |
True
|
set_owner
|
bool
|
Whether to se the window owner. Defaults to True. |
True
|
Source code in pyrevitlib/pyrevit/forms/_ipy.py
merge_resource_dict(xaml_source)
Merge a ResourceDictionary xaml file with this window.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xaml_source
|
str
|
xaml file with the resource dictionary |
required |
Source code in pyrevitlib/pyrevit/forms/_ipy.py
get_locale_string(string_name)
Get localized string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
string_name
|
str
|
string name |
required |
Returns:
| Type | Description |
|---|---|
str
|
localized string |
setup_owner()
setup_resources(wpf_ctrl)
staticmethod
Sets the WPF resources.
Source code in pyrevitlib/pyrevit/forms/_ipy.py
setup_default_handlers()
handle_input_key(sender, args)
set_icon(icon_path)
setup_icon()
hide()
show(modal=False)
show_dialog()
set_image_source_file(wpf_element, image_file)
staticmethod
Set source file for image element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wpf_element
|
Image
|
xaml image element |
required |
image_file
|
str
|
image file path |
required |
Source code in pyrevitlib/pyrevit/forms/_ipy.py
set_image_source(wpf_element, image_file)
Set source file for image element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wpf_element
|
Image
|
xaml image element |
required |
image_file
|
str
|
image file path |
required |
Source code in pyrevitlib/pyrevit/forms/_ipy.py
dispatch(func, *args, **kwargs)
Runs the function in a new thread.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable
|
function to run |
required |
*args
|
Any
|
positional arguments to pass to func |
()
|
**kwargs
|
Any
|
keyword arguments to pass to func |
{}
|
Source code in pyrevitlib/pyrevit/forms/_ipy.py
conceal()
hide_element(*wpf_elements)
staticmethod
Collapse elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*wpf_elements
|
list[UIElement]
|
WPF framework elements to be collaped |
()
|
show_element(*wpf_elements)
staticmethod
Show collapsed elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*wpf_elements
|
list[UIElement]
|
WPF framework elements to be set to visible. |
()
|
Source code in pyrevitlib/pyrevit/forms/_ipy.py
toggle_element(*wpf_elements)
staticmethod
Toggle visibility of elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*wpf_elements
|
list[UIElement]
|
WPF framework elements to be toggled. |
()
|
Source code in pyrevitlib/pyrevit/forms/_ipy.py
disable_element(*wpf_elements)
staticmethod
Enable elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*wpf_elements
|
list[UIElement]
|
WPF framework elements to be enabled |
()
|
enable_element(*wpf_elements)
staticmethod
Enable elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*wpf_elements
|
list[UIElement]
|
WPF framework elements to be enabled |
()
|
handle_url_click(sender, args)
Callback for handling click on package website url.
update_window()
Update the prompt bar to match Revit window.
Source code in pyrevitlib/pyrevit/forms/_ipy.py
WarningBar(height=32, **kwargs)
Bases: TemplatePromptBar
Show warning bar at the top of Revit window.
Other Parameters:
| Name | Type | Description |
|---|---|---|
title |
string
|
warning bar text |
Examples:
Initialize user prompt window.
Source code in pyrevitlib/pyrevit/forms/_ipy.py
Attributes
pyrevit_version
property
Active pyRevit formatted version e.g. '4.9-beta'.
user_height = height
instance-attribute
xaml_source = 'WarningBar.xaml'
class-attribute
instance-attribute
Functions
load_xaml(xaml_source, literal_string=False, handle_esc=True, set_owner=True)
Load the window XAML file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xaml_source
|
str
|
The XAML content or file path to load. |
required |
literal_string
|
bool
|
True if |
False
|
handle_esc
|
bool
|
Whether the ESC key should be handled. Defaults to True. |
True
|
set_owner
|
bool
|
Whether to se the window owner. Defaults to True. |
True
|
Source code in pyrevitlib/pyrevit/forms/_ipy.py
merge_resource_dict(xaml_source)
Merge a ResourceDictionary xaml file with this window.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xaml_source
|
str
|
xaml file with the resource dictionary |
required |
Source code in pyrevitlib/pyrevit/forms/_ipy.py
get_locale_string(string_name)
Get localized string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
string_name
|
str
|
string name |
required |
Returns:
| Type | Description |
|---|---|
str
|
localized string |
setup_owner()
setup_resources(wpf_ctrl)
staticmethod
Sets the WPF resources.
Source code in pyrevitlib/pyrevit/forms/_ipy.py
setup_default_handlers()
handle_input_key(sender, args)
set_icon(icon_path)
setup_icon()
hide()
show(modal=False)
show_dialog()
set_image_source_file(wpf_element, image_file)
staticmethod
Set source file for image element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wpf_element
|
Image
|
xaml image element |
required |
image_file
|
str
|
image file path |
required |
Source code in pyrevitlib/pyrevit/forms/_ipy.py
set_image_source(wpf_element, image_file)
Set source file for image element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wpf_element
|
Image
|
xaml image element |
required |
image_file
|
str
|
image file path |
required |
Source code in pyrevitlib/pyrevit/forms/_ipy.py
dispatch(func, *args, **kwargs)
Runs the function in a new thread.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable
|
function to run |
required |
*args
|
Any
|
positional arguments to pass to func |
()
|
**kwargs
|
Any
|
keyword arguments to pass to func |
{}
|
Source code in pyrevitlib/pyrevit/forms/_ipy.py
conceal()
hide_element(*wpf_elements)
staticmethod
Collapse elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*wpf_elements
|
list[UIElement]
|
WPF framework elements to be collaped |
()
|
show_element(*wpf_elements)
staticmethod
Show collapsed elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*wpf_elements
|
list[UIElement]
|
WPF framework elements to be set to visible. |
()
|
Source code in pyrevitlib/pyrevit/forms/_ipy.py
toggle_element(*wpf_elements)
staticmethod
Toggle visibility of elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*wpf_elements
|
list[UIElement]
|
WPF framework elements to be toggled. |
()
|
Source code in pyrevitlib/pyrevit/forms/_ipy.py
disable_element(*wpf_elements)
staticmethod
Enable elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*wpf_elements
|
list[UIElement]
|
WPF framework elements to be enabled |
()
|
enable_element(*wpf_elements)
staticmethod
Enable elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*wpf_elements
|
list[UIElement]
|
WPF framework elements to be enabled |
()
|
handle_url_click(sender, args)
Callback for handling click on package website url.
update_window()
Update the prompt bar to match Revit window.
Source code in pyrevitlib/pyrevit/forms/_ipy.py
SearchPrompt(search_db, width, height, **kwargs)
Bases: WPFWindow
Standard prompt for pyRevit search.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
search_db
|
list
|
list of possible search targets |
required |
width
|
int
|
width of search prompt window |
required |
height
|
int
|
height of search prompt window |
required |
Other Parameters:
| Name | Type | Description |
|---|---|---|
search_tip |
str
|
text to show in grayscale when search box is empty |
switches |
str
|
list of switches |
Returns:
| Type | Description |
|---|---|
tuple[str, dict] | str
|
matched string if switches are not provided, matched strings, and dict of switches otherwise. |
Examples:
from pyrevit import forms
# assume search input of '/switch1 target1'
matched_str, args, switches = forms.SearchPrompt.show(
search_db=['target1', 'target2', 'target3', 'target4'],
switches=['/switch1', '/switch2'],
search_tip='pyRevit Search'
)
matched_str
'target1'
args
['--help', '--branch', 'branchname']
switches
{'/switch1': True, '/switch2': False}
Initialize search prompt window.
Source code in pyrevitlib/pyrevit/forms/_ipy.py
Attributes
pyrevit_version
property
Active pyRevit formatted version e.g. '4.9-beta'.
Width = width
instance-attribute
MinWidth = self.Width
instance-attribute
Height = height
instance-attribute
search_tip = kwargs.get('search_tip', '')
instance-attribute
search_input
property
writable
Current search input.
search_input_parts
property
Current cleaned up search term.
search_term
property
Current cleaned up search term.
search_term_switches
property
Find matching switches in search term.
search_term_args
property
Find arguments in search term.
search_term_main
property
Current cleaned up search term without the listed switches.
search_matches
property
List of matches for the given search term.
Functions
load_xaml(xaml_source, literal_string=False, handle_esc=True, set_owner=True)
Load the window XAML file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xaml_source
|
str
|
The XAML content or file path to load. |
required |
literal_string
|
bool
|
True if |
False
|
handle_esc
|
bool
|
Whether the ESC key should be handled. Defaults to True. |
True
|
set_owner
|
bool
|
Whether to se the window owner. Defaults to True. |
True
|
Source code in pyrevitlib/pyrevit/forms/_ipy.py
merge_resource_dict(xaml_source)
Merge a ResourceDictionary xaml file with this window.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xaml_source
|
str
|
xaml file with the resource dictionary |
required |
Source code in pyrevitlib/pyrevit/forms/_ipy.py
get_locale_string(string_name)
Get localized string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
string_name
|
str
|
string name |
required |
Returns:
| Type | Description |
|---|---|
str
|
localized string |
setup_owner()
setup_resources(wpf_ctrl)
staticmethod
Sets the WPF resources.
Source code in pyrevitlib/pyrevit/forms/_ipy.py
setup_default_handlers()
handle_input_key(sender, args)
set_icon(icon_path)
setup_icon()
hide()
show_dialog()
set_image_source_file(wpf_element, image_file)
staticmethod
Set source file for image element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wpf_element
|
Image
|
xaml image element |
required |
image_file
|
str
|
image file path |
required |
Source code in pyrevitlib/pyrevit/forms/_ipy.py
set_image_source(wpf_element, image_file)
Set source file for image element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wpf_element
|
Image
|
xaml image element |
required |
image_file
|
str
|
image file path |
required |
Source code in pyrevitlib/pyrevit/forms/_ipy.py
dispatch(func, *args, **kwargs)
Runs the function in a new thread.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable
|
function to run |
required |
*args
|
Any
|
positional arguments to pass to func |
()
|
**kwargs
|
Any
|
keyword arguments to pass to func |
{}
|
Source code in pyrevitlib/pyrevit/forms/_ipy.py
conceal()
hide_element(*wpf_elements)
staticmethod
Collapse elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*wpf_elements
|
list[UIElement]
|
WPF framework elements to be collaped |
()
|
show_element(*wpf_elements)
staticmethod
Show collapsed elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*wpf_elements
|
list[UIElement]
|
WPF framework elements to be set to visible. |
()
|
Source code in pyrevitlib/pyrevit/forms/_ipy.py
toggle_element(*wpf_elements)
staticmethod
Toggle visibility of elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*wpf_elements
|
list[UIElement]
|
WPF framework elements to be toggled. |
()
|
Source code in pyrevitlib/pyrevit/forms/_ipy.py
disable_element(*wpf_elements)
staticmethod
Enable elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*wpf_elements
|
list[UIElement]
|
WPF framework elements to be enabled |
()
|
enable_element(*wpf_elements)
staticmethod
Enable elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*wpf_elements
|
list[UIElement]
|
WPF framework elements to be enabled |
()
|
handle_url_click(sender, args)
Callback for handling click on package website url.
update_results_display(fill_match=False)
Update search prompt results based on current input text.
Source code in pyrevitlib/pyrevit/forms/_ipy.py
set_search_results(*args)
Set search results for returning.
Source code in pyrevitlib/pyrevit/forms/_ipy.py
find_direct_match(input_text)
Find direct text matches in search term.
Source code in pyrevitlib/pyrevit/forms/_ipy.py
find_word_match(input_text)
Find direct word matches in search term.
Source code in pyrevitlib/pyrevit/forms/_ipy.py
search_txt_changed(sender, args)
Handle text changed event.
Source code in pyrevitlib/pyrevit/forms/_ipy.py
handle_kb_key(sender, args)
Handle keyboard input event.
Source code in pyrevitlib/pyrevit/forms/_ipy.py
show(search_db, width=DEFAULT_SEARCHWND_WIDTH, height=DEFAULT_SEARCHWND_HEIGHT, **kwargs)
classmethod
Show search prompt.
Source code in pyrevitlib/pyrevit/forms/_ipy.py
RevisionOption(revision_element)
Bases: TemplateListItem
Revision wrapper for :func:select_revisions.
Source code in pyrevitlib/pyrevit/forms/_ipy.py
Attributes
item = orig_item
instance-attribute
state = checked
instance-attribute
checkable
property
writable
List Item CheckBox Visibility.
name
property
Revision name (description).
Functions
add_PropertyChanged(value)
remove_PropertyChanged(value)
OnPropertyChanged(prop_name)
Called when a property is changed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prop_name
|
str
|
property name |
required |
Source code in pyrevitlib/pyrevit/forms/_ipy.py
unwrap()
SheetOption(sheet_element)
Bases: TemplateListItem
Sheet wrapper for :func:select_sheets.
Source code in pyrevitlib/pyrevit/forms/_ipy.py
Attributes
item = orig_item
instance-attribute
state = checked
instance-attribute
checkable
property
writable
List Item CheckBox Visibility.
name
property
Sheet name.
number
property
Sheet number.
Functions
add_PropertyChanged(value)
remove_PropertyChanged(value)
OnPropertyChanged(prop_name)
Called when a property is changed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prop_name
|
str
|
property name |
required |
Source code in pyrevitlib/pyrevit/forms/_ipy.py
unwrap()
ViewOption(view_element)
Bases: TemplateListItem
View wrapper for :func:select_views.
Source code in pyrevitlib/pyrevit/forms/_ipy.py
Attributes
item = orig_item
instance-attribute
state = checked
instance-attribute
checkable
property
writable
List Item CheckBox Visibility.
name
property
View name.
Functions
add_PropertyChanged(value)
remove_PropertyChanged(value)
OnPropertyChanged(prop_name)
Called when a property is changed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prop_name
|
str
|
property name |
required |
Source code in pyrevitlib/pyrevit/forms/_ipy.py
unwrap()
LevelOption(level_element)
Bases: TemplateListItem
Level wrapper for :func:select_levels.
Source code in pyrevitlib/pyrevit/forms/_ipy.py
Attributes
item = orig_item
instance-attribute
state = checked
instance-attribute
checkable
property
writable
List Item CheckBox Visibility.
name
property
Level name.
Functions
add_PropertyChanged(value)
remove_PropertyChanged(value)
OnPropertyChanged(prop_name)
Called when a property is changed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prop_name
|
str
|
property name |
required |
Source code in pyrevitlib/pyrevit/forms/_ipy.py
unwrap()
FamilyParamOption(fparam, builtin=False, labeled=False, associated=False)
Bases: TemplateListItem
Level wrapper for :func:select_family_parameters.
Source code in pyrevitlib/pyrevit/forms/_ipy.py
Attributes
item = orig_item
instance-attribute
state = checked
instance-attribute
checkable
property
writable
List Item CheckBox Visibility.
isbuiltin = builtin
instance-attribute
islabeled = labeled
instance-attribute
isassociated = associated
instance-attribute
name
property
Family Parameter name.
istype
property
Is type parameter.
Functions
add_PropertyChanged(value)
remove_PropertyChanged(value)
OnPropertyChanged(prop_name)
Called when a property is changed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prop_name
|
str
|
property name |
required |
Source code in pyrevitlib/pyrevit/forms/_ipy.py
unwrap()
WPFWindow(*args, **kwargs)
TemplateUserInputWindow(*args, **kwargs)
Bases: WPFWindow
Source code in pyrevitlib/pyrevit/forms/_cpy.py
SelectFromList(*args, **kwargs)
Bases: TemplateUserInputWindow
Source code in pyrevitlib/pyrevit/forms/_cpy.py
CommandSwitchWindow(*args, **kwargs)
Bases: TemplateUserInputWindow
Source code in pyrevitlib/pyrevit/forms/_cpy.py
ProgressBar(*args, **kwargs)
Functions
get_elementid_value_func()
Returns the ElementId value extraction function based on the Revit version.
Follows API changes in Revit 2024.
Returns:
| Name | Type | Description |
|---|---|---|
function |
A function returns the value of an ElementId. |
Examples:
get_elementid_value = get_elementid_value_func()
sheet_revids = {get_elementid_value(x) for x in self.revit_sheet.GetAllRevisionIds()}
add_sheet_revids = {get_elementid_value(x) for x in self.revit_sheet.GetAdditionalRevisionIds()}
Source code in pyrevitlib/pyrevit/compat.py
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:
| Name | Type | Description | Default |
|---|---|---|---|
logger_name
|
str
|
logger name |
required |
Returns:
| Type | Description |
|---|---|
LoggerWrapper
|
logger object wrapper python's native logger |
Examples:
Source code in pyrevitlib/pyrevit/coreutils/logger.py
is_registered_dockable_panel(panel_type)
Check if dockable panel is already registered.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
panel_type
|
WPFPanel
|
dockable panel type |
required |
Source code in pyrevitlib/pyrevit/forms/_ipy.py
register_dockable_panel(panel_type, default_visible=True)
Register dockable panel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
panel_type
|
WPFPanel
|
dockable panel type |
required |
default_visible
|
bool
|
whether panel should be visible by default |
True
|
Source code in pyrevitlib/pyrevit/forms/_ipy.py
open_dockable_panel(panel_type_or_id)
Open previously registered dockable panel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
panel_type_or_id
|
(WPFPanel, str)
|
panel type or id |
required |
close_dockable_panel(panel_type_or_id)
Close previously registered dockable panel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
panel_type_or_id
|
(WPFPanel, str)
|
panel type or id |
required |
toggle_dockable_panel(panel_type_or_id, state)
Toggle previously registered dockable panel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
panel_type_or_id
|
WPFPanel | str
|
panel type or id |
required |
state
|
bool
|
True to show the panel, False to hide it. |
required |
Source code in pyrevitlib/pyrevit/forms/_ipy.py
select_revisions(title='Select Revision', button_name='Select', width=DEFAULT_INPUTWINDOW_WIDTH, multiple=True, filterfunc=None, doc=None)
Standard form for selecting revisions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
list window title |
'Select Revision'
|
button_name
|
str
|
list window button caption |
'Select'
|
width
|
int
|
width of list window |
DEFAULT_INPUTWINDOW_WIDTH
|
multiple
|
bool
|
allow multi-selection (uses check boxes). defaults to True |
True
|
filterfunc
|
function
|
filter function to be applied to context items. |
None
|
doc
|
Document
|
source document for revisions; defaults to active document |
None
|
Returns:
| Type | Description |
|---|---|
list[Revision]
|
list of selected revisions |
Examples:
from pyrevit import forms
forms.select_revisions()
[<Autodesk.Revit.DB.Revision object>,
<Autodesk.Revit.DB.Revision object>]
Source code in pyrevitlib/pyrevit/forms/_ipy.py
select_sheets(title='Select Sheets', button_name='Select', width=DEFAULT_INPUTWINDOW_WIDTH, multiple=True, filterfunc=None, doc=None, include_placeholder=True, use_selection=False)
Standard form for selecting sheets.
Sheets are grouped into sheet sets and sheet set can be selected from a drop down box at the top of window.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
list window title |
'Select Sheets'
|
button_name
|
str
|
list window button caption |
'Select'
|
width
|
int
|
width of list window |
DEFAULT_INPUTWINDOW_WIDTH
|
multiple
|
bool
|
allow multi-selection (uses check boxes). defaults to True |
True
|
filterfunc
|
function
|
filter function to be applied to context items. |
None
|
doc
|
Document
|
source document for sheets; defaults to active document |
None
|
include_placeholder
|
bool
|
include a placeholder. Defaults to True |
True
|
use_selection
|
bool
|
ask if user wants to use currently selected sheets. |
False
|
Returns:
| Type | Description |
|---|---|
list[ViewSheet]
|
list of selected sheets |
Examples:
from pyrevit import forms
forms.select_sheets()
[<Autodesk.Revit.DB.ViewSheet object>,
<Autodesk.Revit.DB.ViewSheet object>]
Source code in pyrevitlib/pyrevit/forms/_ipy.py
2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 | |
select_views(title='Select Views', button_name='Select', width=DEFAULT_INPUTWINDOW_WIDTH, multiple=True, filterfunc=None, doc=None, use_selection=False)
Standard form for selecting views.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
list window title |
'Select Views'
|
button_name
|
str
|
list window button caption |
'Select'
|
width
|
int
|
width of list window |
DEFAULT_INPUTWINDOW_WIDTH
|
multiple
|
bool
|
allow multi-selection (uses check boxes). defaults to True |
True
|
filterfunc
|
function
|
filter function to be applied to context items. |
None
|
doc
|
Document
|
source document for views; defaults to active document |
None
|
use_selection
|
bool
|
ask if user wants to use currently selected views. |
False
|
Returns:
| Type | Description |
|---|---|
list[View]
|
list of selected views |
Examples:
from pyrevit import forms
forms.select_views()
[<Autodesk.Revit.DB.View object>,
<Autodesk.Revit.DB.View object>]
Source code in pyrevitlib/pyrevit/forms/_ipy.py
2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 | |
select_levels(title='Select Levels', button_name='Select', width=DEFAULT_INPUTWINDOW_WIDTH, multiple=True, filterfunc=None, doc=None, use_selection=False)
Standard form for selecting levels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
list window title |
'Select Levels'
|
button_name
|
str
|
list window button caption |
'Select'
|
width
|
int
|
width of list window |
DEFAULT_INPUTWINDOW_WIDTH
|
multiple
|
bool
|
allow multi-selection (uses check boxes). defaults to True |
True
|
filterfunc
|
function
|
filter function to be applied to context items. |
None
|
doc
|
Document
|
source document for levels; defaults to active document |
None
|
use_selection
|
bool
|
ask if user wants to use currently selected levels. |
False
|
Returns:
| Type | Description |
|---|---|
list[Level]
|
list of selected levels |
Examples:
from pyrevit import forms
forms.select_levels()
[<Autodesk.Revit.DB.Level object>,
<Autodesk.Revit.DB.Level object>]
Source code in pyrevitlib/pyrevit/forms/_ipy.py
2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 | |
select_viewtemplates(title='Select View Templates', button_name='Select', width=DEFAULT_INPUTWINDOW_WIDTH, multiple=True, filterfunc=None, doc=None)
Standard form for selecting view templates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
list window title |
'Select View Templates'
|
button_name
|
str
|
list window button caption |
'Select'
|
width
|
int
|
width of list window |
DEFAULT_INPUTWINDOW_WIDTH
|
multiple
|
bool
|
allow multi-selection (uses check boxes). defaults to True |
True
|
filterfunc
|
function
|
filter function to be applied to context items. |
None
|
doc
|
Document
|
source document for views; defaults to active document |
None
|
Returns:
| Type | Description |
|---|---|
list[View]
|
list of selected view templates |
Examples:
from pyrevit import forms
forms.select_viewtemplates()
[<Autodesk.Revit.DB.View object>,
<Autodesk.Revit.DB.View object>]
Source code in pyrevitlib/pyrevit/forms/_ipy.py
select_schedules(title='Select Schedules', button_name='Select', width=DEFAULT_INPUTWINDOW_WIDTH, multiple=True, filterfunc=None, doc=None)
Standard form for selecting schedules.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
list window title |
'Select Schedules'
|
button_name
|
str
|
list window button caption |
'Select'
|
width
|
int
|
width of list window |
DEFAULT_INPUTWINDOW_WIDTH
|
multiple
|
bool
|
allow multi-selection (uses check boxes). defaults to True |
True
|
filterfunc
|
function
|
filter function to be applied to context items. |
None
|
doc
|
Document
|
source document for views; defaults to active document |
None
|
Returns:
| Type | Description |
|---|---|
list[ViewSchedule]
|
list of selected schedules |
Examples:
from pyrevit import forms
forms.select_schedules()
[<Autodesk.Revit.DB.ViewSchedule object>,
<Autodesk.Revit.DB.ViewSchedule object>]
Source code in pyrevitlib/pyrevit/forms/_ipy.py
select_open_docs(title='Select Open Documents', button_name='OK', width=DEFAULT_INPUTWINDOW_WIDTH, multiple=True, check_more_than_one=True, filterfunc=None)
Standard form for selecting open documents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
list window title |
'Select Open Documents'
|
button_name
|
str
|
list window button caption |
'OK'
|
width
|
int
|
width of list window |
DEFAULT_INPUTWINDOW_WIDTH
|
multiple
|
bool
|
allow multi-selection (uses check boxes). defaults to True |
True
|
check_more_than_one
|
bool
|
|
True
|
filterfunc
|
function
|
filter function to be applied to context items. |
None
|
Returns:
| Type | Description |
|---|---|
list[Document]
|
list of selected documents |
Examples:
from pyrevit import forms
forms.select_open_docs()
[<Autodesk.Revit.DB.Document object>,
<Autodesk.Revit.DB.Document object>]
Source code in pyrevitlib/pyrevit/forms/_ipy.py
select_titleblocks(title='Select Titleblock', button_name='Select', no_tb_option='No Title Block', width=DEFAULT_INPUTWINDOW_WIDTH, multiple=False, filterfunc=None, doc=None)
Standard form for selecting a titleblock.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
list window title |
'Select Titleblock'
|
button_name
|
str
|
list window button caption |
'Select'
|
no_tb_option
|
str
|
name of option for no title block |
'No Title Block'
|
width
|
int
|
width of list window |
DEFAULT_INPUTWINDOW_WIDTH
|
multiple
|
bool
|
allow multi-selection (uses check boxes). defaults to False |
False
|
filterfunc
|
function
|
filter function to be applied to context items. |
None
|
doc
|
Document
|
source document for titleblocks; defaults to active document |
None
|
Returns:
| Type | Description |
|---|---|
ElementId
|
selected titleblock id. |
Examples:
Source code in pyrevitlib/pyrevit/forms/_ipy.py
select_swatch(title='Select Color Swatch', button_name='Select')
Standard form for selecting a color swatch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
swatch list window title |
'Select Color Swatch'
|
button_name
|
str
|
swatch list window button caption |
'Select'
|
Returns:
| Type | Description |
|---|---|
RGB
|
rgb color |
Examples:
Source code in pyrevitlib/pyrevit/forms/_ipy.py
select_image(images, title='Select Image', button_name='Select')
Standard form for selecting an image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images
|
list[str] | list[BitmapImage]
|
list of image file paths or bitmaps |
required |
title
|
str
|
swatch list window title |
'Select Image'
|
button_name
|
str
|
swatch list window button caption |
'Select'
|
Returns:
| Type | Description |
|---|---|
str
|
path of the selected image |
Examples:
from pyrevit import forms
forms.select_image(['C:/path/to/image1.png',
'C:/path/to/image2.png'],
title="Select Variation")
'C:/path/to/image1.png'
Source code in pyrevitlib/pyrevit/forms/_ipy.py
select_parameters(src_element, title='Select Parameters', button_name='Select', multiple=True, filterfunc=None, include_instance=True, include_type=True, exclude_readonly=True)
Standard form for selecting parameters from given element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src_element
|
Element
|
source element |
required |
title
|
str
|
list window title |
'Select Parameters'
|
button_name
|
str
|
list window button caption |
'Select'
|
multiple
|
bool
|
allow multi-selection (uses check boxes). defaults to True |
True
|
filterfunc
|
function
|
filter function to be applied to context items. |
None
|
include_instance
|
bool
|
list instance parameters |
True
|
include_type
|
bool
|
list type parameters |
True
|
exclude_readonly
|
bool
|
only shows parameters that are editable |
True
|
Returns:
| Type | Description |
|---|---|
list[ParamDef]
|
list of paramdef objects |
Examples:
forms.select_parameter(
src_element,
title='Select Parameters',
multiple=True,
include_instance=True,
include_type=True
)
[<ParamDef >, <ParamDef >]
Source code in pyrevitlib/pyrevit/forms/_ipy.py
2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 | |
select_family_parameters(family_doc, title='Select Parameters', button_name='Select', multiple=True, filterfunc=None, include_instance=True, include_type=True, include_builtin=True, include_labeled=True, include_associated=True)
Standard form for selecting parameters from given family document.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
family_doc
|
Document
|
source family document |
required |
title
|
str
|
list window title |
'Select Parameters'
|
button_name
|
str
|
list window button caption |
'Select'
|
multiple
|
bool
|
allow multi-selection (uses check boxes). defaults to True |
True
|
filterfunc
|
function
|
filter function to be applied to context items. |
None
|
include_instance
|
bool
|
list instance parameters |
True
|
include_type
|
bool
|
list type parameters |
True
|
include_builtin
|
bool
|
list builtin parameters |
True
|
include_labeled
|
bool
|
list parameters used as labels |
True
|
include_associated
|
bool
|
list parameters associated to others |
True
|
Returns:
| Type | Description |
|---|---|
list[FamilyParameter]
|
list of family parameter objects |
Examples:
forms.select_family_parameters(
family_doc,
title='Select Parameters',
multiple=True,
include_instance=True,
include_type=True
)
[<DB.FamilyParameter >, <DB.FamilyParameter >]
Source code in pyrevitlib/pyrevit/forms/_ipy.py
2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 | |
alert(msg, title=None, sub_msg=None, expanded=None, footer='', ok=True, cancel=False, yes=False, no=False, retry=False, warn_icon=True, options=None, exitscript=False)
Show a task dialog with given message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
msg
|
str
|
message to be displayed |
required |
title
|
str
|
task dialog title |
None
|
sub_msg
|
str
|
sub message, use html to create clickable links |
None
|
expanded
|
str
|
expanded area message |
None
|
footer
|
str
|
footer text |
''
|
ok
|
bool
|
show OK button, defaults to True |
True
|
cancel
|
bool
|
show Cancel button, defaults to False |
False
|
yes
|
bool
|
show Yes button, defaults to False |
False
|
no
|
bool
|
show NO button, defaults to False |
False
|
retry
|
bool
|
show Retry button, defaults to False |
False
|
warn_icon
|
bool
|
show warning icon |
True
|
options
|
list[str]
|
list of command link titles in order |
None
|
exitscript
|
bool
|
exit if cancel or no, defaults to False |
False
|
Returns:
| Type | Description |
|---|---|
bool
|
True if okay, yes, or retry, otherwise False |
Examples:
from pyrevit import forms
forms.alert('Are you sure?',
sub_msg='<a href=\"https://discourse.pyrevitlabs.io/ \">Click here if you are not sure and want to go to the pyRevit Forum</a>',
ok=False, yes=True, no=True, exitscript=True)
Source code in pyrevitlib/pyrevit/forms/_ipy.py
2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 | |
alert_ifnot(condition, msg, *args, **kwargs)
Show a task dialog with given message if condition is NOT met.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
condition
|
bool
|
condition to test |
required |
msg
|
str
|
message to be displayed |
required |
*args
|
Any
|
additional arguments |
()
|
**kwargs
|
Any
|
additional keyword arguments |
{}
|
Other Parameters:
| Name | Type | Description |
|---|---|---|
title |
str
|
task dialog title |
ok |
bool
|
show OK button, defaults to True |
cancel |
bool
|
show Cancel button, defaults to False |
yes |
bool
|
show Yes button, defaults to False |
no |
bool
|
show NO button, defaults to False |
retry |
bool
|
show Retry button, defaults to False |
exitscript |
bool
|
exit if cancel or no, defaults to False |
Returns:
| Type | Description |
|---|---|
bool
|
True if okay, yes, or retry, otherwise False |
Examples:
from pyrevit import forms
forms.alert_ifnot(value > 12,
'Are you sure?',
ok=False, yes=True, no=True, exitscript=True)
Source code in pyrevitlib/pyrevit/forms/_ipy.py
result_item_result_clicked(sender, e, debug=False)
save_file(file_ext='', files_filter='', init_dir='', default_name='', restore_dir=True, unc_paths=False, title=None)
Save file dialog to select a destination file for data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
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 |
True
|
unc_paths
|
bool
|
return unc paths |
False
|
title
|
str
|
text to show in the title bar |
None
|
Returns:
| Type | Description |
|---|---|
str
|
file path |
Examples:
Source code in pyrevitlib/pyrevit/forms/_ipy.py
pick_excel_file(save=False, title=None)
File pick/save dialog for an excel file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
save
|
bool
|
show file save dialog, instead of file pick dialog |
False
|
title
|
str
|
text to show in the title bar |
None
|
Returns:
| Type | Description |
|---|---|
str
|
file path |
Source code in pyrevitlib/pyrevit/forms/_ipy.py
save_excel_file(title=None)
File save dialog for an excel file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
text to show in the title bar |
None
|
Returns:
| Type | Description |
|---|---|
str
|
file path |
check_workshared(doc=None, message='Model is not workshared.')
Verify if model is workshared and notify user if not.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
doc
|
Document
|
target document, current of not provided |
None
|
message
|
str
|
prompt message if returning False |
'Model is not workshared.'
|
Returns:
| Type | Description |
|---|---|
bool
|
True if doc is workshared |
Source code in pyrevitlib/pyrevit/forms/_ipy.py
check_selection(exitscript=False, message='At least one element must be selected.')
Verify if selection is not empty notify user if it is.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exitscript
|
bool
|
exit script if returning False |
False
|
message
|
str
|
prompt message if returning False |
'At least one element must be selected.'
|
Returns:
| Type | Description |
|---|---|
bool
|
True if selection has at least one item |
Source code in pyrevitlib/pyrevit/forms/_ipy.py
check_familydoc(doc=None, family_cat=None, exitscript=False)
Verify document is a Family and notify user if not.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
doc
|
Document
|
target document, current of not provided |
None
|
family_cat
|
str
|
family category name |
None
|
exitscript
|
bool
|
exit script if returning False |
False
|
Returns:
| Type | Description |
|---|---|
bool
|
True if doc is a Family and of provided category |
Examples:
Source code in pyrevitlib/pyrevit/forms/_ipy.py
check_modeldoc(doc=None, exitscript=False)
Verify document is a not a Model and notify user if not.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
doc
|
Document
|
target document, current of not provided |
None
|
exitscript
|
bool
|
exit script if returning False |
False
|
Returns:
| Type | Description |
|---|---|
bool
|
True if doc is a Model |
Examples:
Source code in pyrevitlib/pyrevit/forms/_ipy.py
check_modelview(view, exitscript=False)
Verify target view is a model view.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view
|
View
|
target view |
required |
exitscript
|
bool
|
exit script if returning False |
False
|
Returns:
| Type | Description |
|---|---|
bool
|
True if view is model view |
Examples:
Source code in pyrevitlib/pyrevit/forms/_ipy.py
check_viewtype(view, view_type, exitscript=False)
Verify target view is of given type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view
|
View
|
target view |
required |
view_type
|
ViewType
|
type of view |
required |
exitscript
|
bool
|
exit script if returning False |
False
|
Returns:
| Type | Description |
|---|---|
bool
|
True if view is of given type |
Examples:
Source code in pyrevitlib/pyrevit/forms/_ipy.py
check_graphicalview(view, exitscript=False)
Verify target view is a graphical view.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view
|
View
|
target view |
required |
exitscript
|
bool
|
exit script if returning False |
False
|
Returns:
| Type | Description |
|---|---|
bool
|
True if view is a graphical view |
Examples:
Source code in pyrevitlib/pyrevit/forms/_ipy.py
toast(message, title='pyRevit', appid='pyRevit', icon=None, click=None, actions=None)
Show a Windows 10 notification.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
notification message |
required |
title
|
str
|
notification title |
'pyRevit'
|
appid
|
str
|
app name (will show under message) |
'pyRevit'
|
icon
|
str
|
file path to icon .ico file (defaults to pyRevit icon) |
None
|
click
|
str
|
click action commands string |
None
|
actions
|
dict
|
dictionary of button names and action strings |
None
|
Examples:
script.toast("Hello World!",
title="My Script",
appid="MyAPP",
click="https://pyrevitlabs.github.io/pyRevit/",
actions={
"Open Google":"https://google.com",
"Open Toast64":"https://github.com/go-toast/toast"
})
Source code in pyrevitlib/pyrevit/forms/_ipy.py
ask_to_use_selected(type_name, count=None, multiple=True)
Ask user if wants to use currently selected elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_name
|
str
|
Element type of expected selected elements |
required |
count
|
int
|
Number of selected items |
None
|
multiple
|
bool
|
Whether multiple selected items are allowed |
True
|
Source code in pyrevitlib/pyrevit/forms/_ipy.py
ask_for_color(default=None)
Show system color picker and ask for color.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
default
|
str
|
default color in HEX ARGB e.g. #ff808080 |
None
|
Returns:
| Type | Description |
|---|---|
str
|
selected color in HEX ARGB e.g. #ff808080, or None if cancelled |
Examples:
Source code in pyrevitlib/pyrevit/forms/_ipy.py
inform_wip()
Show work-in-progress prompt to user and exit script.
Examples: