Fix create_shape() overloads because SWIG does not map None for us anymore

This commit is contained in:
Thomas Krijnen
2026-01-13 08:44:30 +01:00
parent 07a01bcf54
commit 7e5248da29
2 changed files with 7 additions and 2 deletions
@@ -507,7 +507,7 @@ def create_shape(
""" """
return wrap_shape_creation( return wrap_shape_creation(
settings, settings,
ifcopenshell_wrapper.create_shape(settings, inst, repr if repr is not None else None, geometry_library), ifcopenshell_wrapper.create_shape(settings, inst, repr, geometry_library) if repr else ifcopenshell_wrapper.create_shape(settings, inst, geometry_library),
) )
+6 -1
View File
@@ -1040,7 +1040,7 @@ ifcopenshell::geometry::taxonomy::item::ptr try_upcast(PyObject* obj0, swig_type
%} %}
%inline %{ %inline %{
static std::variant<IfcGeom::Element*, IfcGeom::Representation::Representation*, IfcGeom::Transformation*> create_shape(ifcopenshell::geometry::Settings& settings, const express::Base& instance, const express::Base& representation = express::Base(), const char* const geometry_library="opencascade") { static std::variant<IfcGeom::Element*, IfcGeom::Representation::Representation*, IfcGeom::Transformation*> create_shape(ifcopenshell::geometry::Settings& settings, const express::Base& instance, const express::Base& representation, const char* const geometry_library="opencascade") {
const std::string& schema_name = instance.declaration().schema()->name(); const std::string& schema_name = instance.declaration().schema()->name();
#ifdef HAS_SCHEMA_2x3 #ifdef HAS_SCHEMA_2x3
@@ -1106,6 +1106,11 @@ ifcopenshell::geometry::taxonomy::item::ptr try_upcast(PyObject* obj0, swig_type
throw IfcParse::IfcException("No geometry support for " + schema_name); throw IfcParse::IfcException("No geometry support for " + schema_name);
} }
// Manual definition of overload without representation argument
static std::variant<IfcGeom::Element*, IfcGeom::Representation::Representation*, IfcGeom::Transformation*> create_shape(ifcopenshell::geometry::Settings& settings, const express::Base& instance, const char* const geometry_library="opencascade") {
return create_shape(settings, instance, express::Base(), geometry_library);
}
%} %}
#ifdef IFOPSH_WITH_OPENCASCADE #ifdef IFOPSH_WITH_OPENCASCADE