| 183 | } |
| 184 | |
| 185 | PyObject* GroupExtensionPy::removeObject(PyObject* args) |
| 186 | { |
| 187 | PyObject* object; |
| 188 | if (!PyArg_ParseTuple(args, "O!", &(DocumentObjectPy::Type), &object)) { |
| 189 | return nullptr; |
| 190 | } |
| 191 | |
| 192 | DocumentObjectPy* docObj = static_cast<DocumentObjectPy*>(object); |
| 193 | if (!docObj->getDocumentObjectPtr() |
| 194 | || !docObj->getDocumentObjectPtr()->isAttachedToDocument()) { |
| 195 | PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot remove an invalid object"); |
| 196 | return nullptr; |
| 197 | } |
| 198 | if (docObj->getDocumentObjectPtr()->getDocument() |
| 199 | != getGroupExtensionPtr()->getExtendedObject()->getDocument()) { |
| 200 | PyErr_SetString(Base::PyExc_FC_GeneralError, |
| 201 | "Cannot remove an object from another document from this group"); |
| 202 | return nullptr; |
| 203 | } |
| 204 | |
| 205 | GroupExtension* grp = getGroupExtensionPtr(); |
| 206 | |
| 207 | auto vec = grp->removeObject(docObj->getDocumentObjectPtr()); |
| 208 | Py::List list; |
| 209 | for (App::DocumentObject* obj : vec) { |
| 210 | list.append(Py::asObject(obj->getPyObject())); |
| 211 | } |
| 212 | |
| 213 | return Py::new_reference_to(list); |
| 214 | } |
| 215 | |
| 216 | PyObject* GroupExtensionPy::removeObjects(PyObject* args) |
| 217 | { |
nothing calls this directly
no test coverage detected