Part: Command to show list of extensions from Python

This commit is contained in:
Abdullah Tahiri
2019-02-11 06:56:37 +01:00
committed by wmayer
parent 665fcda4dc
commit d99e667e30
2 changed files with 38 additions and 0 deletions

View File

@@ -291,6 +291,39 @@ PyObject* GeometryPy::getExtension(PyObject *args)
return 0;
}
PyObject* GeometryPy::showExtensions(PyObject *args)
{
if (!PyArg_ParseTuple(args, "")){
PyErr_SetString(PartExceptionOCCError, "No arguments were expected");
return NULL;
}
try {
const std::vector<std::weak_ptr<GeometryExtension>> ext = this->getGeometryPtr()->getExtensions();
Py::Tuple tuple(ext.size());
for (std::size_t i=0; i<ext.size(); ++i) {
std::stringstream str;
std::shared_ptr<GeometryExtension> p = ext[i].lock();
if(p) {
str << "<" << p->getTypeId().getName() << ", \"" << p->getName() << "\">";
tuple.setItem(i, Py::String(str.str()));
}
}
return Py::new_reference_to(tuple);
}
catch(Base::ValueError e) {
PyErr_SetString(PartExceptionOCCError, e.what());
return 0;
}
}
Py::Boolean GeometryPy::getConstruction(void) const
{
return Py::Boolean(getGeometryPtr()->Construction);