pyrevit.coreutils.ribbon¶
Base module to interact with Revit ribbon.
-
class
pyrevit.coreutils.ribbon.
ButtonIcons
(image_file)¶ Bases:
object
pyRevit ui element icon.
Upon init, this type reads the given image file into an io stream and releases the os lock on the file.
Parameters: image_file (str) – image file path to be used as icon -
icon_file_path
¶ icon image file path
Type: str
-
filestream
¶ io stream containing image binary data
Type: IO.FileStream
-
check_icon_size
()¶ Verify icon size is within acceptable range.
-
create_bitmap
(icon_size)¶ Resamples image and creates bitmap for the given size.
Icons are assumed to be square.
Parameters: icon_size (int) – icon size (width or height) Returns: object containing image data at given size Return type: Imaging.BitmapSource
-
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
Common base type for native Revit API UI containers.
-
activate
()¶ Activate this container in ui.
Under current implementation, raises PyRevitUIError exception as native Revit API UI components should not be changed.
-
deactivate
()¶ Deactivate this container in ui.
Under current implementation, raises PyRevitUIError exception as native Revit API UI components should not be changed.
-
static
is_native
()¶ Is this container generated by pyRevit or is native.
-
-
exception
pyrevit.coreutils.ribbon.
PyRevitUIError
¶ Bases:
pyrevit.PyRevitException
Common base class for all pyRevit ui-related exceptions.
-
class
pyrevit.coreutils.ribbon.
RevitNativeRibbonButton
(adwnd_ribbon_button)¶ Bases:
pyrevit.coreutils.ribbon.GenericRevitNativeUIContainer
Revit API UI native ribbon button.
-
class
pyrevit.coreutils.ribbon.
RevitNativeRibbonGroupItem
(adwnd_ribbon_item)¶ Bases:
pyrevit.coreutils.ribbon.GenericRevitNativeUIContainer
Revit API UI native ribbon button.
Get button item with given name.
Parameters: name (str) – name of button item to find Returns: button object if found Return type: RevitNativeRibbonButton
-
class
pyrevit.coreutils.ribbon.
RevitNativeRibbonPanel
(adwnd_ribbon_panel)¶ Bases:
pyrevit.coreutils.ribbon.GenericRevitNativeUIContainer
Revit API UI native ribbon button.
-
ribbon_item
(item_name)¶ Get panel item with given name.
Parameters: item_name (str) – name of panel item to find Returns: panel item if found, could be RevitNativeRibbonButton
orRevitNativeRibbonGroupItem
Return type: object
-
-
class
pyrevit.coreutils.ribbon.
RevitNativeRibbonTab
(adwnd_ribbon_tab)¶ Bases:
pyrevit.coreutils.ribbon.GenericRevitNativeUIContainer
Revit API UI native ribbon tab.
-
static
is_pyrevit_tab
()¶ Is this tab generated by pyRevit.
-
ribbon_panel
(panel_name)¶ Get panel with given name.
Parameters: panel_name (str) – name of panel to find Returns: panel if found Return type: RevitNativeRibbonPanel
-
static
-
pyrevit.coreutils.ribbon.
get_current_ui
(all_native=False)¶ Revit UI Wrapper class for interacting with current pyRevit UI.
Returned class provides min required functionality for user interaction
Example
>>> current_ui = pyrevit.session.current_ui() >>> this_script = pyrevit.session.get_this_command() >>> current_ui.update_button_icon(this_script, new_icon)
Returns: wrapper around active ribbon gui Return type: _PyRevitUI
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