Make PartDesign::Boolean work with new Link structure

This is the first feature that used GeoFeatureGroupExtension and required links to the groups inside as well as to things on the same level. Hence a few modifications to link scopes have been nesseccary.
This commit is contained in:
Stefan Tröger
2017-08-04 20:08:52 +02:00
committed by wmayer
parent 4fa3005343
commit 8841fb0805
15 changed files with 124 additions and 83 deletions

View File

@@ -131,6 +131,44 @@ PyObject* GroupExtensionPy::addObjects(PyObject *args) {
throw Base::TypeError(error);
};
PyObject* GroupExtensionPy::setObjects(PyObject *args) {
PyObject *object;
if (!PyArg_ParseTuple(args, "O", &object)) // convert args: Python->C
return NULL; // NULL triggers exception
if (PyTuple_Check(object) || PyList_Check(object)) {
Py::Sequence list(object);
Py::Sequence::size_type size = list.size();
std::vector<DocumentObject*> values;
values.resize(size);
for (Py::Sequence::size_type i = 0; i < size; i++) {
Py::Object item = list[i];
if (!PyObject_TypeCheck(*item, &(DocumentObjectPy::Type))) {
std::string error = std::string("type in list must be 'DocumentObject', not ");
error += (*item)->ob_type->tp_name;
throw Base::TypeError(error);
}
values[i] = static_cast<DocumentObjectPy*>(*item)->getDocumentObjectPtr();
}
GroupExtension* grp = getGroupExtensionPtr();
auto vec = grp->setObjects(values);
Py::List result;
for (App::DocumentObject* obj : vec)
result.append(Py::asObject(obj->getPyObject()));
return Py::new_reference_to(result);
}
std::string error = std::string("type must be list of 'DocumentObject', not ");
error += object->ob_type->tp_name;
throw Base::TypeError(error);
};
PyObject* GroupExtensionPy::removeObject(PyObject *args)
{
PyObject *object;