Files
IFC-Exporter-Grasshopper/utils/mapper.py
T
2026-03-19 16:58:08 +01:00

22 lines
735 B
Python

# =============================================================================
# mapper.py
# Maps Speckle objects → IFC entity classes.
#
# Reads the IFC class from _properties.Attributes.type
# Falls back to IfcBuildingElementProxy if not present.
# =============================================================================
from utils.properties import get_attributes
def classify(obj) -> str:
"""
Determine the IFC class for a Speckle object.
Reads from _properties.Attributes.type. Falls back to IfcBuildingElementProxy.
"""
attrs = get_attributes(obj)
ifc_type = attrs.get("type")
if ifc_type and isinstance(ifc_type, str):
return ifc_type.strip()
return "IfcBuildingElementProxy"