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

Method getCustomAttributes

src/App/DocumentPyImp.cpp:1058–1081  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1056}
1057
1058PyObject* DocumentPy::getCustomAttributes(const char* attr) const
1059{
1060 // Note: Here we want to return only a document object if its
1061 // name matches 'attr'. However, it is possible to have an object
1062 // with the same name as an attribute. If so, we return 0 as other-
1063 // wise it wouldn't be possible to address this attribute any more.
1064 // The object must then be addressed by the getObject() method directly.
1065 App::Property* prop = getPropertyContainerPtr()->getPropertyByName(attr);
1066 if (prop) {
1067 return nullptr;
1068 }
1069 if (!this->ob_type->tp_dict) {
1070 if (PyType_Ready(this->ob_type) < 0) {
1071 return nullptr;
1072 }
1073 }
1074 PyObject* item = PyDict_GetItemString(this->ob_type->tp_dict, attr);
1075 if (item) {
1076 return nullptr;
1077 }
1078 // search for an object with this name
1079 DocumentObject* obj = getDocumentPtr()->getObject(attr);
1080 return (obj ? obj->getPyObject() : nullptr);
1081}
1082
1083int DocumentPy::setCustomAttributes(const char* attr, PyObject*)
1084{

Callers

nothing calls this directly

Calls 3

getPropertyByNameMethod · 0.45
getObjectMethod · 0.45
getPyObjectMethod · 0.45

Tested by

no test coverage detected