| 61 | |
| 62 | |
| 63 | def _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 | |
| 92 | def _make_filtered_iterator(model: ifcopenshell.file, include_elements: list[Any]) -> ifcopenshell.geom.iterator: |