| 318 | } |
| 319 | |
| 320 | PyObject* MaterialManagerPy::filterMaterials(PyObject* args, PyObject* kwds) |
| 321 | { |
| 322 | PyObject* filterPy {}; |
| 323 | PyObject* includeLegacy = Py_False; |
| 324 | static const std::array<const char*, 3> kwds_save{ "filter", |
| 325 | "includeLegacy", |
| 326 | nullptr }; |
| 327 | if (!Base::Wrapped_ParseTupleAndKeywords(args, |
| 328 | kwds, |
| 329 | // "O|O!", |
| 330 | "O!|O!", |
| 331 | kwds_save, |
| 332 | &MaterialFilterPy::Type, |
| 333 | &filterPy, |
| 334 | &PyBool_Type, |
| 335 | &includeLegacy)) { |
| 336 | return nullptr; |
| 337 | } |
| 338 | |
| 339 | MaterialFilterOptions options; |
| 340 | options.setIncludeFavorites(false); |
| 341 | options.setIncludeRecent(false); |
| 342 | options.setIncludeEmptyFolders(false); |
| 343 | options.setIncludeEmptyLibraries(false); |
| 344 | options.setIncludeLegacy(PyObject_IsTrue(includeLegacy)); |
| 345 | |
| 346 | auto filter = std::make_shared<MaterialFilter>(*(static_cast<MaterialFilterPy*>(filterPy)->getMaterialFilterPtr())); |
| 347 | |
| 348 | auto libraries = getMaterialManagerPtr()->getLibraries(); |
| 349 | Py::List list; |
| 350 | |
| 351 | for (auto lib : *libraries) { |
| 352 | auto tree = getMaterialManagerPtr()->getMaterialTree(*lib, *filter, options); |
| 353 | if (tree->size() > 0) { |
| 354 | addMaterials(getMaterialManagerPtr(), list, tree); |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | Py_INCREF(*list); |
| 359 | return *list; |
| 360 | } |
| 361 | |
| 362 | PyObject* MaterialManagerPy::refresh(PyObject* /*args*/) |
| 363 | { |