mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 17:57:02 +00:00
Accept list of entity instances from Python
This commit is contained in:
@@ -65,7 +65,7 @@ void Ifc::IfcUntypedEntity::setArgument(unsigned int i) {
|
|||||||
bool is_optional = Ifc2x3::Type::GetAttributeOptional(_type, i);
|
bool is_optional = Ifc2x3::Type::GetAttributeOptional(_type, i);
|
||||||
if (is_optional) {
|
if (is_optional) {
|
||||||
writable_entity()->setArgument(i);
|
writable_entity()->setArgument(i);
|
||||||
} else invalid_argument(i,"NONE");
|
} else invalid_argument(i,"NULL");
|
||||||
}
|
}
|
||||||
void Ifc::IfcUntypedEntity::setArgument(unsigned int i, int v) {
|
void Ifc::IfcUntypedEntity::setArgument(unsigned int i, int v) {
|
||||||
IfcUtil::ArgumentType arg_type = Ifc2x3::Type::GetAttributeType(_type,i);
|
IfcUtil::ArgumentType arg_type = Ifc2x3::Type::GetAttributeType(_type,i);
|
||||||
|
|||||||
@@ -190,7 +190,11 @@ std::string IfcWriteEntityListArgument::toString(bool upper) const {
|
|||||||
if ( Ifc2x3::Type::IsSimple(e->type()) ) {
|
if ( Ifc2x3::Type::IsSimple(e->type()) ) {
|
||||||
ss << e->toString(upper);
|
ss << e->toString(upper);
|
||||||
} else {
|
} else {
|
||||||
ss << "#" << e->id();
|
if (e->file) {
|
||||||
|
ss << "#" << e->id();
|
||||||
|
} else {
|
||||||
|
ss << "#?";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ss << ")";
|
ss << ")";
|
||||||
@@ -323,7 +327,11 @@ std::string IfcWriteIntegralArgument::toString(bool upper) const {
|
|||||||
if ( Ifc2x3::Type::IsSimple(e->type()) ) {
|
if ( Ifc2x3::Type::IsSimple(e->type()) ) {
|
||||||
ss << e->toString(upper);
|
ss << e->toString(upper);
|
||||||
} else {
|
} else {
|
||||||
ss << "#" << e->id();
|
if (e->file) {
|
||||||
|
ss << "#" << e->id();
|
||||||
|
} else {
|
||||||
|
ss << "#?";
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
break;
|
break;
|
||||||
default: throw IfcParse::IfcException("Invalid cast");
|
default: throw IfcParse::IfcException("Invalid cast");
|
||||||
|
|||||||
@@ -41,6 +41,30 @@
|
|||||||
%rename("__repr__") toString;
|
%rename("__repr__") toString;
|
||||||
%rename("Entity") IfcUntypedEntity;
|
%rename("Entity") IfcUntypedEntity;
|
||||||
|
|
||||||
|
%typemap(typecheck,precedence=SWIG_TYPECHECK_INTEGER) IfcEntities {
|
||||||
|
$1 = (PySequence_Check($input) && !PyUnicode_Check($input) && !PyString_Check($input)) ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
%typemap(in) IfcEntities {
|
||||||
|
if (PySequence_Check($input)) {
|
||||||
|
$1 = std::make_shared<IfcEntityList>();
|
||||||
|
for(Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
|
||||||
|
PyObject* obj = PySequence_GetItem($input, i);
|
||||||
|
if (obj) {
|
||||||
|
void *arg = 0;
|
||||||
|
int res = SWIG_ConvertPtr(obj, &arg, SWIGTYPE_p_Ifc__IfcUntypedEntity, 0);
|
||||||
|
if (!SWIG_IsOK(res)) {
|
||||||
|
SWIG_exception_fail(SWIG_ArgError(res), "in method '" "Entity__set_argument" "', argument " "3"" of type '" "Ifc::IfcUntypedEntity *""'");
|
||||||
|
} else {
|
||||||
|
$1->push(reinterpret_cast<Ifc::IfcUntypedEntity*>(arg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
SWIG_exception(SWIG_RuntimeError,"Unknown argument type");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
%typemap(out) IfcEntities {
|
%typemap(out) IfcEntities {
|
||||||
const unsigned size = $1 ? $1->Size() : 0;
|
const unsigned size = $1 ? $1->Size() : 0;
|
||||||
$result = PyList_New(size);
|
$result = PyList_New(size);
|
||||||
|
|||||||
Reference in New Issue
Block a user