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

Method getSubObject

src/App/DocumentObjectPyImp.cpp:532–693  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

530}
531
532PyObject* DocumentObjectPy::getSubObject(PyObject* args, PyObject* keywds)
533{
534 enum class ReturnType
535 {
536 PyObject = 0,
537 DocObject = 1,
538 DocAndPyObject = 2,
539 Placement = 3,
540 Matrix = 4,
541 LinkAndPlacement = 5,
542 LinkAndMatrix = 6
543 };
544
545 PyObject* obj;
546 short retType = 0;
547 PyObject* pyMat = nullptr;
548 PyObject* doTransform = Py_True;
549 short depth = 0;
550
551 static const std::array<const char*, 6> kwlist {"subname",
552 "retType",
553 "matrix",
554 "transform",
555 "depth",
556 nullptr};
557 if (!Base::Wrapped_ParseTupleAndKeywords(args,
558 keywds,
559 "O|hO!O!h",
560 kwlist,
561 &obj,
562 &retType,
563 &Base::MatrixPy::Type,
564 &pyMat,
565 &PyBool_Type,
566 &doTransform,
567 &depth)) {
568 return nullptr;
569 }
570
571 if (retType < 0 || static_cast<size_t>(retType) > kwlist.size()) {
572 PyErr_SetString(PyExc_ValueError, "invalid retType, can only be integer 0~6");
573 return nullptr;
574 }
575
576 ReturnType retEnum = ReturnType(retType);
577 std::vector<std::string> subs;
578 bool single = true;
579
580 if (PyUnicode_Check(obj)) {
581 subs.emplace_back(PyUnicode_AsUTF8(obj));
582 }
583 else if (PySequence_Check(obj)) {
584 single = false;
585 Py::Sequence shapeSeq(obj);
586 for (Py::Sequence::iterator it = shapeSeq.begin(); it != shapeSeq.end(); ++it) {
587 PyObject* item = (*it).ptr();
588 if (PyUnicode_Check(item)) {
589 subs.emplace_back(PyUnicode_AsUTF8(item));

Callers

nothing calls this directly

Calls 15

asBooleanFunction · 0.85
MatrixClass · 0.85
new_reference_toFunction · 0.85
ReturnTypeEnum · 0.70
PlacementClass · 0.70
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
ptrMethod · 0.45
backMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected