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

Function _highlight_css_from_ids

src/ifcquery/ifcquery/plot.py:63–89  ·  view source on GitHub ↗
(model: ifcopenshell.file, element_ids: list[int])

Source from the content-addressed store, hash-verified

61
62
63def _highlight_css_from_ids(model: ifcopenshell.file, element_ids: list[int]) -> str:
64 guids: list[str] = []
65 for sid in element_ids:
66 try:
67 e = model.by_id(int(sid))
68 except RuntimeError:
69 continue
70 if e is None:
71 continue
72 gid = getattr(e, "GlobalId", None)
73 if isinstance(gid, str) and gid:
74 guids.append(gid)
75
76 if not guids:
77 return ""
78
79 attr = _escape_css_attr("ifc:guid")
80
81 css = [
82 "/* Auto-highlight injected by ifcquery.plot */",
83 f"[{attr}] path {{ opacity: 0.10; }}",
84 f"[{attr}] text {{ opacity: 0.25; }}",
85 ]
86 for gid in guids:
87 css.append(f'[{attr}="{gid}"] path {{ opacity: 1.0; stroke: #d00; stroke-width: 0.25; }}')
88 css.append(f'[{attr}="{gid}"] text {{ opacity: 1.0; fill: #d00; }}')
89 return "\n".join(css) + "\n"
90
91
92def _make_filtered_iterator(model: ifcopenshell.file, include_elements: list[Any]) -> ifcopenshell.geom.iterator:

Callers 4

plotFunction · 0.85

Calls 4

_escape_css_attrFunction · 0.85
by_idMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45

Tested by 3