Return a helpful error message when ifcopenshell.draw produces no geometry groups.
(model: ifcopenshell.file, view: str)
| 119 | |
| 120 | |
| 121 | def _diagnose_empty_drawing(model: ifcopenshell.file, view: str) -> str: |
| 122 | """Return a helpful error message when ifcopenshell.draw produces no geometry groups.""" |
| 123 | hints = [] |
| 124 | |
| 125 | if view in ("floorplan", "auto"): |
| 126 | storeys = model.by_type("IfcBuildingStorey") |
| 127 | if not storeys: |
| 128 | hints.append("the model has no IfcBuildingStorey entities (required for auto_floorplan)") |
| 129 | else: |
| 130 | null_elevation = [s for s in storeys if getattr(s, "Elevation", None) is None] |
| 131 | if null_elevation: |
| 132 | names = ", ".join(f'"{s.Name or s.GlobalId}"' for s in null_elevation) |
| 133 | hints.append( |
| 134 | f"storey Elevation is None for: {names} — " |
| 135 | "set IfcBuildingStorey.Elevation (e.g. 0.0) so the section cut height can be determined" |
| 136 | ) |
| 137 | |
| 138 | has_geom = any(getattr(e, "Representation", None) is not None for e in model.by_type("IfcProduct")) |
| 139 | if not has_geom: |
| 140 | hints.append("no IfcProduct entities have geometric representations") |
| 141 | |
| 142 | base = f"No plan geometry found for view={view!r}." |
| 143 | if hints: |
| 144 | return base + " Possible causes: " + "; ".join(hints) + "." |
| 145 | return base + " The model may lack geometry visible in this view." |
| 146 | |
| 147 | |
| 148 | def plot( |