diff --git a/src/ifcgeom/mapping/mapping.cpp b/src/ifcgeom/mapping/mapping.cpp index 53926f2aef..2da6b2d36b 100644 --- a/src/ifcgeom/mapping/mapping.cpp +++ b/src/ifcgeom/mapping/mapping.cpp @@ -258,9 +258,20 @@ void mapping::get_representations(std::vector& tasks, const IfcUtil::IfcBaseEntity* mapping::get_product_type(const IfcUtil::IfcBaseEntity* product_) { auto product = product_->as(); +#ifdef SCHEMA_IfcObject_HAS_IsTypedBy auto rels = product->IsTypedBy(); +#else // IFC2X3. + auto rels = product->IsDefinedBy(); +#endif for (auto it = rels->begin(); it != rels->end(); ++it) { +#ifdef SCHEMA_IfcObject_HAS_IsTypedBy auto rel = *it; +#else // IFC2X3. + IfcSchema::IfcRelDefinesByType* rel = (*it)->as(); + if (rel == nullptr) { + continue; + } +#endif // Avoid segfault if RelatingType is unset. if (rel->get("RelatingType")->isNull()){ break;