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

Function main

src/ifcopenshell-python/ifcopenshell/draw.py:101–669  ·  view source on GitHub ↗
(
    settings: draw_settings,
    files: list[ifcopenshell.file],
    iterators: Sequence[ifcopenshell.geom.iterator] = (),
    merge_projection: bool = True,
    progress_function: Callable = DO_NOTHING,
)

Source from the content-addressed store, hash-verified

99
100
101def 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 )

Callers 1

draw.pyFile · 0.70

Calls 15

by_guidFunction · 0.85
yield_groupsFunction · 0.85
pythonizeFunction · 0.85
clrFunction · 0.85
svg_to_coordlistFunction · 0.85
create_polyFunction · 0.85
has_relevant_zoneFunction · 0.85
type_unsafe_valueClass · 0.85
union_findFunction · 0.85
classesFunction · 0.85
polygon_to_svg_pathFunction · 0.85
splitMethod · 0.80

Tested by

no test coverage detected