From 1d56736d7524de34410b42e4e5a2c32fc6890bda Mon Sep 17 00:00:00 2001 From: Bruno Postle Date: Fri, 6 Mar 2026 15:18:55 +0000 Subject: [PATCH] shape_builder: warn about mixed item types in get_representation Generated with the assistance of an AI coding tool. --- .../ifcopenshell/util/shape_builder.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/util/shape_builder.py b/src/ifcopenshell-python/ifcopenshell/util/shape_builder.py index 04344f2cf3..524f9fed98 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/shape_builder.py +++ b/src/ifcopenshell-python/ifcopenshell/util/shape_builder.py @@ -1116,10 +1116,22 @@ class ShapeBuilder: ) -> ifcopenshell.entity_instance: """Create IFC representation for the specified context and items. + **All items must belong to the same geometry category.** IFC prohibits + mixing incompatible item types in one representation (e.g. + ``IfcExtrudedAreaSolid`` with ``IfcBlock``, or solids with curves). + When ``representation_type`` is omitted the type is inferred via + :func:`ifcopenshell.util.representation.guess_type`; if the items are + heterogeneous ``guess_type`` returns ``None`` and the representation is + written with no ``RepresentationType``, which fails IFC validation. + Avoid mixing swept-solid primitives (``IfcExtrudedAreaSolid``, + ``IfcRevolvedAreaSolid``) with CSG primitives (``IfcBlock``, + ``IfcSphere``, etc.) or any other category in a single call. + :param context: IfcGeometricRepresentationSubContext - :param items: could be a list or single curve/IfcExtrudedAreaSolid + :param items: A single item or list of items, all of the same geometry + category (e.g. all ``IfcExtrudedAreaSolid``, all ``IfcIndexedPolyCurve``) :param representation_type: Explicitly specified RepresentationType. - If not provided it will be guessed from the items types + If not provided it will be guessed from the items types. :return: IfcShapeRepresentation """ if not isinstance(items, collections.abc.Iterable):