ifcopenshell.util.selector
¶
Module Contents¶
- exception ifcopenshell.util.selector.SetElementValueException¶
Bases:
Exception
Common base class for all non-exit exceptions.
Initialize self. See help(type(self)) for accurate signature.
- class ifcopenshell.util.selector.FacetTransformer(ifc_file: ifcopenshell.file, elements: set[ifcopenshell.entity_instance] | None = None)¶
Bases:
lark.Transformer
- add_default_elements()¶
- attribute(args)¶
- classification(args)¶
- compare(element_value, comparison, value) bool ¶
- comparison(args)¶
- entity(args)¶
- facet_list(args)¶
- get_container_tree(container: ifcopenshell.entity_instance) list[ifcopenshell.entity_instance] ¶
- get_results() set[ifcopenshell.entity_instance] ¶
- group(args)¶
- instance(args)¶
- keys(args)¶
- location(args)¶
- material(args)¶
- parent(args)¶
- prop(args)¶
- property(args)¶
- pset(args)¶
- query(args)¶
- type(args)¶
- value(args)¶
- base_elements: set[ifcopenshell.entity_instance] | None¶
- container_trees: dict[ifcopenshell.entity_instance, list[ifcopenshell.entity_instance]]¶
- elements: set[ifcopenshell.entity_instance]¶
- file¶
- has_additive_facet_in_current_list = False¶
- results: list[set[ifcopenshell.entity_instance]]¶
- class ifcopenshell.util.selector.FormatTransformer¶
Bases:
lark.Transformer
- ESCAPED_STRING(args)¶
- NUMBER(args)¶
- concat(args)¶
- format_length(args)¶
- function(args)¶
- imperial_length(args)¶
- int(args: list[str]) str ¶
- lower(args)¶
- metric_length(args)¶
- number(args)¶
- round(args)¶
- start(args)¶
- substr(args)¶
- title(args)¶
- upper(args)¶
- class ifcopenshell.util.selector.GetElementTransformer¶
Bases:
lark.Transformer
- ESCAPED_STRING(args)¶
- key(args)¶
- keys(args)¶
- quoted_string(args)¶
- regex_string(args)¶
- start(args)¶
- unquoted_string(args)¶
- ifcopenshell.util.selector.filter_elements(ifc_file: ifcopenshell.file, query: str, elements: set[ifcopenshell.entity_instance] | None = None, edit_in_place=False) set[ifcopenshell.entity_instance] ¶
Filter elements based on the provided query.
- Parameters:
ifc_file – The IFC file object
query – Query to execute
elements – Base set of IFC elements for the query. If not provided, all elements in the IFC are queried. If provided, the query will be applied to this set of elements, so the result will be a subset of elements.
edit_in_place – If True, mutate the provided elements in place. Defaults to False
- Returns:
Set of filtered elements
Example:
# Select all the walls and slabs in the file. elements = ifcopenshell.util.selector.filter_elements(ifc_file, "IfcWall, IfcSlab") # Add doors to the elements too. elements = ifcopenshell.util.selector.filter_elements(ifc_file, "IfcDoor", elements) # Changed our mind, exclude the slabs. elements = ifcopenshell.util.selector.filter_elements(ifc_file, "! IfcSlab", elements) # {#1=IfcWall(...), #2=IfcDoor(...)} print(elements)
- ifcopenshell.util.selector.format(query: str) str ¶
- ifcopenshell.util.selector.get_element_value(element: ifcopenshell.entity_instance, query: str) Any ¶
- ifcopenshell.util.selector.set_element_value(ifc_file: ifcopenshell.file, element: ifcopenshell.entity_instance | dict[str, Any] | Iterable[ifcopenshell.entity_instance] | None, query: str | list[str], value: Any, *, concat: str = ', ') None ¶
Set element value based on the provided query.
- Parameters:
element – IFC element to change.
query – String query to identify the attribute to change.
value – Value to set.
concat – Concatenation symbol, used only to deserialize property set enum values from string values.
- ifcopenshell.util.selector.filter_elements_grammar¶
- ifcopenshell.util.selector.format_grammar¶
- ifcopenshell.util.selector.get_element_grammar¶