MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / _get_scope_elements

Function _get_scope_elements

src/ifcquery/ifcquery/clash.py:39–63  ·  view source on GitHub ↗

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
)

Source from the content-addressed store, hash-verified

37
38
39def _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
66def _build_tree(model: ifcopenshell.file, elements: set[ifcopenshell.entity_instance]) -> ifcopenshell.geom.tree | None:

Callers 1

clashFunction · 0.85

Calls 5

printFunction · 0.85
setFunction · 0.50
get_containerMethod · 0.45
idMethod · 0.45
by_typeMethod · 0.45

Tested by

no test coverage detected