MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / removeObject

Method removeObject

src/App/GroupExtensionPyImp.cpp:185–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

183}
184
185PyObject* 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
216PyObject* GroupExtensionPy::removeObjects(PyObject* args)
217{

Callers

nothing calls this directly

Calls 6

new_reference_toFunction · 0.85
isAttachedToDocumentMethod · 0.45
getDocumentMethod · 0.45
getExtendedObjectMethod · 0.45
appendMethod · 0.45
getPyObjectMethod · 0.45

Tested by

no test coverage detected