diff --git a/src/ifcparse/IfcUntypedEntity.cpp b/src/ifcparse/IfcUntypedEntity.cpp index a7e62cbbf9..bd2ce55a67 100644 --- a/src/ifcparse/IfcUntypedEntity.cpp +++ b/src/ifcparse/IfcUntypedEntity.cpp @@ -61,6 +61,12 @@ void Ifc::IfcUntypedEntity::invalid_argument(unsigned int i, const std::string& const std::string arg_name = Ifc2x3::Type::GetAttributeName(_type,i); throw IfcException(t + " is not a valid type for '" + arg_name + "'"); } +void Ifc::IfcUntypedEntity::setArgument(unsigned int i) { + bool is_optional = Ifc2x3::Type::GetAttributeOptional(_type, i); + if (is_optional) { + writable_entity()->setArgument(i); + } else invalid_argument(i,"NONE"); +} void Ifc::IfcUntypedEntity::setArgument(unsigned int i, int v) { IfcUtil::ArgumentType arg_type = Ifc2x3::Type::GetAttributeType(_type,i); if (arg_type == Argument_INT) { diff --git a/src/ifcparse/IfcUntypedEntity.h b/src/ifcparse/IfcUntypedEntity.h index c1827a7c5e..0c6f663df8 100644 --- a/src/ifcparse/IfcUntypedEntity.h +++ b/src/ifcparse/IfcUntypedEntity.h @@ -27,6 +27,7 @@ namespace Ifc { const char* getArgumentName(unsigned int i) const; unsigned getArgumentIndex(const std::string& a) const; + void setArgument(unsigned int iz); void setArgument(unsigned int i, int v); void setArgument(unsigned int i, bool v); void setArgument(unsigned int i, double v); diff --git a/src/ifcwrap/IfcPython.i b/src/ifcwrap/IfcPython.i index 02179b3210..f0e58dbf4d 100644 --- a/src/ifcwrap/IfcPython.i +++ b/src/ifcwrap/IfcPython.i @@ -37,7 +37,7 @@ %rename("get_argument_type") getArgumentType; %rename("get_argument_name") getArgumentName; %rename("get_argument_index") getArgumentIndex; -%rename("set_argument") setArgument; +%rename("_set_argument") setArgument; %rename("__repr__") toString; %rename("Entity") IfcUntypedEntity; @@ -144,11 +144,16 @@ $self->AddEntity(e); } void write(const std::string& fn) { - std::ofstream f(fn.c_str()); + std::ofstream f(fn); f << (*$self); } } +%extend Ifc::IfcUntypedEntity { + %pythoncode %{ + set_argument = lambda self,x,y: self._set_argument(x) if y is None else self._set_argument(x,y) + %} +} namespace std { %template(Ints) vector; diff --git a/src/ifcwrap/Interface.h b/src/ifcwrap/Interface.h index 043fcaf968..9eff58f00a 100644 --- a/src/ifcwrap/Interface.h +++ b/src/ifcwrap/Interface.h @@ -28,6 +28,7 @@ namespace Ifc { const char* getArgumentName(unsigned int i) const; unsigned getArgumentIndex(const std::string& a) const; + void setArgument(unsigned int i); void setArgument(unsigned int i, int v); void setArgument(unsigned int i, bool v); void setArgument(unsigned int i, double v);