This commit is contained in:
Andrej730
2024-07-02 11:40:38 +05:00
parent 5d1b2e4651
commit 8f92877fb4
6 changed files with 46 additions and 28 deletions
+9 -9
View File
@@ -27,6 +27,7 @@ import ifcopenshell.geom
from xml.dom.minidom import parseString
from dataclasses import dataclass, fields
from typing import Callable, Sequence
import numpy
@@ -64,7 +65,13 @@ class draw_settings:
unify_inputs: bool = True
def main(settings, files, iterators=None, merge_projection=True, progress_function=DO_NOTHING):
def main(
settings: draw_settings,
files: list[ifcopenshell.file],
iterators: Sequence[ifcopenshell.geom.iterator] = (),
merge_projection: bool = True,
progress_function: Callable = DO_NOTHING,
):
geom_settings = ifcopenshell.geom.settings(
# when not doing booleans, proper solids from shells isn't a requirement
@@ -97,13 +104,6 @@ def main(settings, files, iterators=None, merge_projection=True, progress_functi
for it in iterators:
it.set_cache(cache)
def yield_from_iterator(it):
if it.initialize():
while True:
yield it.get()
if not it.next():
break
# Initialize serializer
buffer = ifcopenshell.geom.serializers.buffer()
serialiser_settings = ifcopenshell.geom.serializer_settings()
@@ -167,7 +167,7 @@ def main(settings, files, iterators=None, merge_projection=True, progress_functi
# Loop over iterators for geometric content
for i, it in enumerate(iterators):
for elem in yield_from_iterator(it):
for elem in it:
sr.write(elem)
if elem.type != "IfcSpace":
tree.add_element(elem)
@@ -365,6 +365,8 @@ def create_shape(
Note that in Python, you must store a reference to the element returned by this function to prevent garbage
collection when you access its children. See #1124.
:raises RuntimeError: If failed to process shape. You can turn detailed logging to get more details.
:return:
- `inst` is IfcProduct and `repr` provided / None -> ShapeElementType
- `inst` is IfcRepresentation and `repr` is None -> ShapeType