selection
Elements selection utilities.
Attributes
mlogger = get_logger(__name__)
module-attribute
Classes
ElementSelection(element_list=None)
Element selection handler.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
element_list |
list[Element]
|
list of selected elements |
None
|
Source code in pyrevitlib/pyrevit/revit/selection.py
Attributes
is_empty
property
elements
property
element_ids
property
first
property
last
property
Functions
get_element_ids(mixed_list)
classmethod
set_to(element_list)
clear()
append(element_list)
include(element_type)
exclude(element_type)
no_views()
only_views()
expand_groups()
Source code in pyrevitlib/pyrevit/revit/selection.py
PickByCategorySelectionFilter(category_id)
Bases: ISelectionFilter
Source code in pyrevitlib/pyrevit/revit/selection.py
Attributes
category_id = category_id
instance-attribute
Functions
AllowElement(element)
Functions
pick_element(message='')
Asks the user to pick an element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message |
str
|
An optional message to display. |
''
|
Returns:
Type | Description |
---|---|
Element
|
element selected by the user. |
Source code in pyrevitlib/pyrevit/revit/selection.py
pick_element_by_category(cat_name_or_builtin, message='')
Returns the element of the specified category picked by the user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cat_name_or_builtin |
str
|
name or built-in category of the element to pick. |
required |
message |
str
|
message to display on selection. Defaults to ''. |
''
|
Returns:
Type | Description |
---|---|
Element
|
picked element. |
Raises:
Type | Description |
---|---|
PyRevitException
|
If no category matches the specified name or builtin. |
Source code in pyrevitlib/pyrevit/revit/selection.py
pick_elementpoint(message='', world=False)
Returns the element point selected by the user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message |
str
|
message to display. Defaults to ''. |
''
|
world |
bool
|
whether to use world coordinates. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
PointOnElement
|
The selected point. |
Source code in pyrevitlib/pyrevit/revit/selection.py
pick_edge(message='')
Returns the edge selected by the user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message |
str
|
message to display. Defaults to ''. |
''
|
Returns:
Type | Description |
---|---|
Edge
|
The selected edge. |
Source code in pyrevitlib/pyrevit/revit/selection.py
pick_face(message='')
Returns the face selected by the user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message |
str
|
message to display. Defaults to ''. |
''
|
Returns:
Type | Description |
---|---|
Face
|
The selected face. |
Source code in pyrevitlib/pyrevit/revit/selection.py
pick_linked(message='')
Returns the linked element selected by the user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message |
str
|
message to display. Defaults to ''. |
''
|
Returns:
Type | Description |
---|---|
LinkedElement
|
The selected linked element. |
Source code in pyrevitlib/pyrevit/revit/selection.py
pick_elements(message='')
Asks the user to pick multiple elements.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message |
str
|
An optional message to display. |
''
|
Returns:
Type | Description |
---|---|
list[Element]
|
elements selected by the user. |
Source code in pyrevitlib/pyrevit/revit/selection.py
pick_elements_by_category(cat_name_or_builtin, message='')
Returns the elements of the specified category picked by the user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cat_name_or_builtin |
str
|
name or built-in category of the elements to pick. |
required |
message |
str
|
message to display on selection. Defaults to ''. |
''
|
Returns:
Type | Description |
---|---|
list[Element]
|
picked elements. |
Raises:
Type | Description |
---|---|
PyRevitException
|
If no category matches the specified name or builtin. |
Source code in pyrevitlib/pyrevit/revit/selection.py
get_picked_elements(message='')
Allows the user to pick multple elements, one at a time.
It keeps asking the user to pick an element until no elements are selected.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message |
str
|
The message to display. Defaults to ''. |
''
|
Yields:
Type | Description |
---|---|
Element
|
selected element |
Source code in pyrevitlib/pyrevit/revit/selection.py
get_picked_elements_by_category(cat_name_or_builtin, message='')
Pick elements by category.
Keeps asking the user to pick an element until no elements are selected.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cat_name_or_builtin |
str
|
category name or built-in category. |
required |
message |
str
|
message to display while picking elements. |
''
|
Yields:
Type | Description |
---|---|
Element
|
The picked elements from the specified category. |
Source code in pyrevitlib/pyrevit/revit/selection.py
pick_elementpoints(message='', world=False)
Selects element points.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message |
str
|
The message to display when selecting element points. |
''
|
world |
bool
|
Select points in world coordinates. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
list[PointOnElement]
|
selected element points. |
Source code in pyrevitlib/pyrevit/revit/selection.py
pick_edges(message='')
Selects edges.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message |
str
|
The message to display when selecting edges. |
''
|
Returns:
Type | Description |
---|---|
list[Edge]
|
selected edges. |
Source code in pyrevitlib/pyrevit/revit/selection.py
pick_faces(message='')
Selects faces.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message |
str
|
The message to display when selecting the faces. |
''
|
Returns:
Type | Description |
---|---|
list[Face]
|
selected faces. |
Source code in pyrevitlib/pyrevit/revit/selection.py
pick_linkeds(message='')
Selects linked elements.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message |
str
|
The message to display when selecting linked elements. |
''
|
Returns:
Type | Description |
---|---|
list[LinkedElement]
|
selected linked elements. |
Source code in pyrevitlib/pyrevit/revit/selection.py
pick_point(message='')
Pick a point from the user interface.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message |
str
|
A message to display when prompting for the point. |
''
|
Returns:
Type | Description |
---|---|
tuple or None
|
A tuple representing the picked point as (x, y, z) coordinates, or None if no point was picked or an error occurred. |
Source code in pyrevitlib/pyrevit/revit/selection.py
pick_rectangle(message='', pick_filter=None)
Picks elements from the user interface by specifying a rectangular area.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message |
str
|
A custom message to display when prompting the user to pick elements. Default is an empty string. |
''
|
pick_filter |
object
|
An object specifying the filter to apply when picking elements. Default is None. |
None
|
Returns:
Type | Description |
---|---|
list[ElementId]
|
The selected elements. |
Source code in pyrevitlib/pyrevit/revit/selection.py
get_selection_category_set()
Returns a CategorySet with the categories of the selected elements.
Returns:
Type | Description |
---|---|
CategorySet
|
categories of the selected elements. |
Source code in pyrevitlib/pyrevit/revit/selection.py
get_selection()
Returns the current selected items.
Returns:
Type | Description |
---|---|
ElementSelection
|
the current selected items |