diff --git a/src/ifcwrap/IfcGeomWrapper.i b/src/ifcwrap/IfcGeomWrapper.i index 05442d59c3..8d52625e6e 100644 --- a/src/ifcwrap/IfcGeomWrapper.i +++ b/src/ifcwrap/IfcGeomWrapper.i @@ -1021,6 +1021,9 @@ ifcopenshell::geometry::taxonomy::item::ptr try_upcast(PyObject* obj0, swig_type %inline %{ ifcopenshell::geometry::taxonomy::item::ptr map_shape(ifcopenshell::geometry::Settings& settings, IfcUtil::IfcBaseClass* instance) { + if (instance->file_ == nullptr) { + throw std::runtime_error("Unable to map instance without file"); + } std::unique_ptr mapping(ifcopenshell::geometry::impl::mapping_implementations().construct(instance->file_, settings)); return mapping->map(instance); }