Return deep inspection data for an element.
(model: ifcopenshell.file, element: ifcopenshell.entity_instance)
| 188 | |
| 189 | |
| 190 | def info(model: ifcopenshell.file, element: ifcopenshell.entity_instance) -> dict[str, Any]: |
| 191 | """Return deep inspection data for an element.""" |
| 192 | result: dict[str, Any] = { |
| 193 | "id": element.id(), |
| 194 | "type": element.is_a(), |
| 195 | } |
| 196 | |
| 197 | # Direct attributes via get_info() which returns a dict of all attributes |
| 198 | element_info = element.get_info() |
| 199 | attrs = {} |
| 200 | for key, value in element_info.items(): |
| 201 | if key in ("id", "type"): |
| 202 | continue |
| 203 | attrs[key] = _serialize_attribute(value) |
| 204 | result["attributes"] = attrs |
| 205 | |
| 206 | # Property sets and quantity sets |
| 207 | try: |
| 208 | psets = ifcopenshell.util.element.get_psets(element) |
| 209 | if psets: |
| 210 | result["property_sets"] = psets |
| 211 | except Exception: |
| 212 | pass |
| 213 | |
| 214 | # Element type |
| 215 | try: |
| 216 | element_type = ifcopenshell.util.element.get_type(element) |
| 217 | if element_type: |
| 218 | type_info: dict[str, Any] = { |
| 219 | "id": element_type.id(), |
| 220 | "type": element_type.is_a(), |
| 221 | } |
| 222 | if hasattr(element_type, "Name"): |
| 223 | type_info["name"] = element_type.Name |
| 224 | result["element_type"] = type_info |
| 225 | except Exception: |
| 226 | pass |
| 227 | |
| 228 | # Material |
| 229 | try: |
| 230 | material = ifcopenshell.util.element.get_material(element) |
| 231 | mat_dict = _material_to_dict(material) |
| 232 | if mat_dict: |
| 233 | result["material"] = mat_dict |
| 234 | except Exception: |
| 235 | pass |
| 236 | |
| 237 | # Spatial container |
| 238 | try: |
| 239 | container = ifcopenshell.util.element.get_container(element) |
| 240 | if container: |
| 241 | result["container"] = { |
| 242 | "id": container.id(), |
| 243 | "type": container.is_a(), |
| 244 | "name": container.Name if hasattr(container, "Name") else None, |
| 245 | } |
| 246 | except Exception: |
| 247 | pass |