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

Method setCustomAttributes

src/App/DocumentPyImp.cpp:1083–1112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1081}
1082
1083int DocumentPy::setCustomAttributes(const char* attr, PyObject*)
1084{
1085 // Note: Here we want to return only a document object if its
1086 // name matches 'attr'. However, it is possible to have an object
1087 // with the same name as an attribute. If so, we return 0 as other-
1088 // wise it wouldn't be possible to address this attribute any more.
1089 // The object must then be addressed by the getObject() method directly.
1090 App::Property* prop = getPropertyContainerPtr()->getPropertyByName(attr);
1091 if (prop) {
1092 return 0;
1093 }
1094 if (!this->ob_type->tp_dict) {
1095 if (PyType_Ready(this->ob_type) < 0) {
1096 return 0;
1097 }
1098 }
1099 PyObject* item = PyDict_GetItemString(this->ob_type->tp_dict, attr);
1100 if (item) {
1101 return 0;
1102 }
1103 DocumentObject* obj = getDocumentPtr()->getObject(attr);
1104 if (obj) {
1105 std::stringstream str;
1106 str << "'Document' object attribute '" << attr << "' must not be set this way" << std::ends;
1107 PyErr_SetString(PyExc_RuntimeError, str.str().c_str());
1108 return -1;
1109 }
1110
1111 return 0;
1112}
1113
1114PyObject* DocumentPy::getLinksTo(PyObject* args)
1115{

Callers

nothing calls this directly

Calls 4

getPropertyByNameMethod · 0.45
getObjectMethod · 0.45
c_strMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected