55bc1b2fa5
* Initial commit * Repo setup * first working version * Optimised mesh conversion * timers * first pass * format * Format * deleted old file * Working grabbing spatial elements, but not all relationships captured * DFS for spatials, itterator for geometry * Second pass, manual traversal * Ok, this is working nicely now * Cleanup * Convert render materials * property set extraction (#2) * various changes (#4) * Fix for non-app.speckle.systems servers (#5) * don't use https for http server urls (#6) * fix(conversion): Filter only IfcRoot classes (#7) * Filter only IfcRoot classes * vscode config * Feat(prop): Added better property extraction (#8) * Added better property extraction * property sets naming * feat: attach attributes that are on the element type level (#9) * Added better property extraction * property sets naming * Get attributes from element type * tidy up (#10) * Add null check (#11) * ruff (#12) * Rendermaterials inherit material names instead of type + unique id (#14) * lock * ruff check * pre-commit * add license files for the speckleifc subpackage --------- Co-authored-by: Sebastian Witt <sebastian.witt@rwth-aachen.de> Co-authored-by: Gergő Jedlicska <57442769+gjedlicska@users.noreply.github.com> Co-authored-by: Gergő Jedlicska <gergo@jedlicska.com>
32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
from collections.abc import Generator, Iterable
|
|
from itertools import chain
|
|
from typing import cast
|
|
|
|
from ifcopenshell.entity_instance import entity_instance
|
|
|
|
|
|
def get_children(step_element: entity_instance) -> Generator[entity_instance]:
|
|
yield from chain(
|
|
get_spatial_children(step_element), get_aggregate_children(step_element)
|
|
)
|
|
|
|
|
|
def get_spatial_children(step_element: entity_instance) -> Generator[entity_instance]:
|
|
spatial_relations = cast(
|
|
Iterable[entity_instance] | None,
|
|
getattr(step_element, "ContainsElements", None),
|
|
)
|
|
if spatial_relations is not None:
|
|
for relation in spatial_relations:
|
|
yield from cast(Iterable[entity_instance], relation.RelatedElements)
|
|
|
|
|
|
def get_aggregate_children(step_element: entity_instance) -> Generator[entity_instance]:
|
|
aggregate_relations = cast(
|
|
Iterable[entity_instance] | None,
|
|
getattr(step_element, "IsDecomposedBy", None),
|
|
)
|
|
if aggregate_relations is not None:
|
|
for relation in aggregate_relations:
|
|
yield from cast(Iterable[entity_instance], relation.RelatedObjects)
|