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

Method getPyPathValue

src/App/PropertyStandard.cpp:599–633  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

597}
598
599bool PropertyEnumeration::getPyPathValue(const ObjectIdentifier& path, Py::Object& r) const
600{
601 std::string p = path.getSubPathStr();
602 if (p == ".Enum" || p == ".All") {
603 Base::PyGILStateLocker lock;
604 auto maxEnumValue = _enum.maxValue();
605 if (maxEnumValue < 0) {
606 return false; // The enum is invalid
607 }
608 Py::Tuple res(maxEnumValue + 1);
609 std::vector<std::string> enums = _enum.getEnumVector();
610 PropertyString tmp;
611 for (int i = 0; i < int(enums.size()); ++i) {
612 tmp.setValue(enums[i]);
613 res.setItem(i, Py::asObject(tmp.getPyObject()));
614 }
615 if (p == ".Enum") {
616 r = res;
617 }
618 else {
619 Py::Tuple tuple(2);
620 tuple.setItem(0, res);
621 tuple.setItem(1, Py::Long(getValue()));
622 r = tuple;
623 }
624 }
625 else if (p == ".String") {
626 auto v = getValueAsString();
627 r = Py::String(v ? v : "");
628 }
629 else {
630 r = Py::Long(getValue());
631 }
632 return true;
633}
634
635//**************************************************************************
636//**************************************************************************

Callers

nothing calls this directly

Calls 8

getSubPathStrMethod · 0.80
maxValueMethod · 0.80
getValueFunction · 0.70
StringClass · 0.70
getEnumVectorMethod · 0.45
sizeMethod · 0.45
setValueMethod · 0.45
getPyObjectMethod · 0.45

Tested by

no test coverage detected