(
settings: draw_settings,
files: list[ifcopenshell.file],
iterators: Sequence[ifcopenshell.geom.iterator] = (),
merge_projection: bool = True,
progress_function: Callable = DO_NOTHING,
)
| 99 | |
| 100 | |
| 101 | def main( |
| 102 | settings: draw_settings, |
| 103 | files: list[ifcopenshell.file], |
| 104 | iterators: Sequence[ifcopenshell.geom.iterator] = (), |
| 105 | merge_projection: bool = True, |
| 106 | progress_function: Callable = DO_NOTHING, |
| 107 | ): |
| 108 | |
| 109 | def by_guid(g): |
| 110 | for f in files: |
| 111 | try: |
| 112 | return f.by_guid(g) |
| 113 | except: |
| 114 | pass |
| 115 | |
| 116 | geom_settings = ifcopenshell.geom.settings( |
| 117 | # when not doing booleans, proper solids from shells isn't a requirement |
| 118 | REORIENT_SHELLS=settings.subtract_before_hlr, |
| 119 | # SVG serialiazation depends on element hierarchy now to look up the parent |
| 120 | ELEMENT_HIERARCHY=True, |
| 121 | ) |
| 122 | |
| 123 | # this is required for serialization |
| 124 | dimensionality = W.CURVES_SURFACES_AND_SOLIDS if settings.include_curves else W.SURFACES_AND_SOLIDS |
| 125 | geom_settings.set("dimensionality", dimensionality) |
| 126 | geom_settings.set("iterator-output", ifcopenshell.ifcopenshell_wrapper.NATIVE) |
| 127 | geom_settings.set("apply-default-materials", True) |
| 128 | |
| 129 | if not iterators: |
| 130 | iterator_kwargs = {} |
| 131 | if settings.include_entities: |
| 132 | iterator_kwargs["include"] = settings.include_entities.split(",") |
| 133 | elif settings.exclude_entities: |
| 134 | iterator_kwargs["exclude"] = settings.exclude_entities.split(",") |
| 135 | |
| 136 | def yield_parents(el): |
| 137 | yield el |
| 138 | if par := ifcopenshell.util.element.get_parent(el): |
| 139 | yield from yield_parents(par) |
| 140 | |
| 141 | def has_selected_parent(el): |
| 142 | return any(settings.storey_filter in (x.Name or x.GlobalId) for x in yield_parents(el)) |
| 143 | |
| 144 | def create_iter(f): |
| 145 | if settings.storey_filter and iterator_kwargs.get("include"): |
| 146 | iterator_kwargs["include"] = list( |
| 147 | filter(has_selected_parent, sum((f.by_type(x) for x in iterator_kwargs["include"]), [])) |
| 148 | ) |
| 149 | return ifcopenshell.geom.iterator(geom_settings, f, **iterator_kwargs) |
| 150 | |
| 151 | # We have to keep the iterator in memory because otherwise |
| 152 | # the styles are cleared up. |
| 153 | iterators = list( |
| 154 | map( |
| 155 | create_iter, |
| 156 | files, |
| 157 | ) |
| 158 | ) |
no test coverage detected