Update flatten.py
build and deploy Speckle functions / publish-automate-function-version (push) Has been cancelled
build and deploy Speckle functions / publish-automate-function-version (push) Has been cancelled
This commit is contained in:
committed by
GitHub
parent
48d6bdbeb1
commit
83dcd0d32f
@@ -1,15 +1,15 @@
|
||||
"""Helper module for a simple speckle object tree flattening."""
|
||||
from typing import List, Optional, Tuple
|
||||
from typing import List, Optional, Tuple, Iterable
|
||||
|
||||
from specklepy.objects import Base
|
||||
from specklepy.objects.other import Instance, Transform
|
||||
|
||||
# def flatten_base(base: Base) -> Iterable[Base]:
|
||||
# """Take a base and flatten it to an iterable of bases."""
|
||||
# if hasattr(base, "elements") and base["elements"] is not None:
|
||||
# for element in base["elements"]:
|
||||
# yield from flatten_base(element)
|
||||
# yield base
|
||||
def flatten_base(base: Base) -> Iterable[Base]:
|
||||
"""Take a base and flatten it to an iterable of bases."""
|
||||
if hasattr(base, "elements") and base["elements"] is not None:
|
||||
for element in base["elements"]:
|
||||
yield from flatten_base(element)
|
||||
yield base
|
||||
|
||||
|
||||
def extract_base_and_transform(
|
||||
|
||||
Reference in New Issue
Block a user