Allow optional arguments to be set from Python with None, e.g: ifc_person.set_argument(0, None)

This commit is contained in:
Thomas Krijnen
2013-07-20 13:51:06 -07:00
parent e5abdb7de8
commit 10657416ea
4 changed files with 15 additions and 2 deletions
+6
View File
@@ -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) {
+1
View File
@@ -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);