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

Method getSubObjects

src/App/FeaturePython.cpp:338–372  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

336}
337
338bool FeaturePythonImp::getSubObjects(std::vector<std::string>& ret, int reason) const
339{
340 FC_PY_CALL_CHECK(getSubObjects);
341 Base::PyGILStateLocker lock;
342 try {
343 Py::Tuple args(2);
344 args.setItem(0, Py::Object(object->getPyObject(), true));
345 args.setItem(1, Py::Long(reason));
346 Py::Object res(Base::pyCall(py_getSubObjects.ptr(), args.ptr()));
347 if (!res.isTrue()) {
348 return true;
349 }
350 if (!res.isSequence()) {
351 throw Py::TypeError("getSubObjects expects return type of tuple");
352 }
353 Py::Sequence seq(res);
354 for (Py_ssize_t i = 0; i < seq.length(); ++i) {
355 Py::Object name(seq[i].ptr());
356 if (!name.isString()) {
357 throw Py::TypeError("getSubObjects expects string in returned sequence");
358 }
359 ret.push_back(name.as_string());
360 }
361 return true;
362 }
363 catch (Py::Exception&) {
364 if (PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
365 PyErr_Clear();
366 return false;
367 }
368 Base::PyException e; // extract the Python error text
369 e.reportException();
370 return true;
371 }
372}
373
374bool FeaturePythonImp::getLinkedObject(DocumentObject*& ret,
375 bool recurse,

Callers 3

_removeObjectMethod · 0.45
TEST_FFunction · 0.45

Calls 8

pyCallFunction · 0.85
ObjectClass · 0.70
getPyObjectMethod · 0.45
ptrMethod · 0.45
lengthMethod · 0.45
push_backMethod · 0.45
as_stringMethod · 0.45
reportExceptionMethod · 0.45

Tested by

no test coverage detected