Return set of elements to check against and the effective scope used. Returns (elements, effective_scope) where effective_scope may differ from the requested scope if fallback was needed.
(
model: ifcopenshell.file, element: ifcopenshell.entity_instance, scope: str
)
| 37 | |
| 38 | |
| 39 | def _get_scope_elements( |
| 40 | model: ifcopenshell.file, element: ifcopenshell.entity_instance, scope: str |
| 41 | ) -> tuple[set[ifcopenshell.entity_instance], str]: |
| 42 | """Return set of elements to check against and the effective scope used. |
| 43 | |
| 44 | Returns (elements, effective_scope) where effective_scope may differ from |
| 45 | the requested scope if fallback was needed. |
| 46 | """ |
| 47 | if scope == "storey": |
| 48 | container = ifcopenshell.util.element.get_container(element) |
| 49 | if container is not None: |
| 50 | siblings = set(ifcopenshell.util.element.get_contained(container)) |
| 51 | siblings.discard(element) |
| 52 | return siblings, "storey" |
| 53 | else: |
| 54 | print( |
| 55 | f"Warning: Element #{element.id()} has no spatial container, falling back to --scope all", |
| 56 | file=sys.stderr, |
| 57 | ) |
| 58 | |
| 59 | # scope == "all" or fallback |
| 60 | elements = set(model.by_type("IfcElement")) |
| 61 | elements -= set(model.by_type("IfcFeatureElement")) |
| 62 | elements.discard(element) |
| 63 | return elements, "all" |
| 64 | |
| 65 | |
| 66 | def _build_tree(model: ifcopenshell.file, elements: set[ifcopenshell.entity_instance]) -> ifcopenshell.geom.tree | None: |