diff --git a/src/Mod/Material/App/MaterialPy.xml b/src/Mod/Material/App/MaterialPy.xml index edd21c589080..e6998690f18b 100644 --- a/src/Mod/Material/App/MaterialPy.xml +++ b/src/Mod/Material/App/MaterialPy.xml @@ -210,5 +210,21 @@ Set the value associated with the property + + + Property keys + + + + + Property values + + + + diff --git a/src/Mod/Material/App/MaterialPyImp.cpp b/src/Mod/Material/App/MaterialPyImp.cpp index 3e4c72c079bd..f650df64a566 100644 --- a/src/Mod/Material/App/MaterialPyImp.cpp +++ b/src/Mod/Material/App/MaterialPyImp.cpp @@ -553,3 +553,35 @@ PyObject* MaterialPy::setAppearanceValue(PyObject* args) Py_INCREF(Py_None); return Py_None; } + +PyObject* MaterialPy::keys() +{ + return Py::new_reference_to(this->getProperties().keys()); +} + +PyObject* MaterialPy::values() +{ + return Py::new_reference_to(this->getProperties().values()); +} + +Py_ssize_t MaterialPy::sequence_length(PyObject *self) +{ + return static_cast(self)->getProperties().size(); +} + +PyObject* MaterialPy::sequence_item(PyObject* self, Py_ssize_t item) +{ + Py::List keys = static_cast(self)->getProperties().keys(); + return Py::new_reference_to(keys.getItem(item)); +} + +int MaterialPy::sequence_contains(PyObject* self, PyObject* key) +{ + return PyDict_Contains(static_cast(self)->getProperties().ptr(), key); +} + +PyObject* MaterialPy::mapping_subscript(PyObject* self, PyObject* key) +{ + Py::Dict dict = static_cast(self)->getProperties(); + return Py::new_reference_to(dict.getItem(Py::Object(key))); +}