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

Method allowObject

src/App/GroupExtensionPyImp.cpp:340–364  ·  view source on GitHub ↗

def allowObject(self, obj: Any) -> bool:

Source from the content-addressed store, hash-verified

338
339// def allowObject(self, obj: Any) -> bool:
340PyObject* GroupExtensionPy::allowObject(PyObject* args)
341{
342 PyObject* object;
343 if (!PyArg_ParseTuple(args, "O!", &(DocumentObjectPy::Type), &object)) {
344 return nullptr;
345 }
346
347 auto* docObj = static_cast<DocumentObjectPy*>(object);
348 if (!docObj->getDocumentObjectPtr()
349 || !docObj->getDocumentObjectPtr()->isAttachedToDocument()) {
350 PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot check an invalid object");
351 return nullptr;
352 }
353 if (docObj->getDocumentObjectPtr()->getDocument()
354 != getGroupExtensionPtr()->getExtendedObject()->getDocument()) {
355 PyErr_SetString(Base::PyExc_FC_GeneralError,
356 "Cannot check an object from another document from this group");
357 return nullptr;
358 }
359
360 GroupExtension* grp = getGroupExtensionPtr();
361
362 bool allowed = grp->allowObject(docObj->getDocumentObjectPtr());
363 return PyBool_FromLong(allowed ? 1 : 0);
364}

Callers 1

Calls 3

isAttachedToDocumentMethod · 0.45
getDocumentMethod · 0.45
getExtendedObjectMethod · 0.45

Tested by

no test coverage detected