Convert an IFC attribute value to a JSON-serializable form.
(value: Any)
| 166 | |
| 167 | |
| 168 | def _serialize_attribute(value: Any) -> Any: |
| 169 | """Convert an IFC attribute value to a JSON-serializable form.""" |
| 170 | if isinstance(value, ifcopenshell.entity_instance): |
| 171 | return {"id": value.id(), "type": value.is_a()} |
| 172 | if isinstance(value, tuple): |
| 173 | return [_serialize_attribute(v) for v in value] |
| 174 | return value |
| 175 | |
| 176 | |
| 177 | def _material_to_dict(material: ifcopenshell.entity_instance | None) -> dict[str, Any] | None: |