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

Method filterMaterials

src/Mod/Material/App/MaterialManagerPyImp.cpp:320–360  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

318}
319
320PyObject* 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
362PyObject* MaterialManagerPy::refresh(PyObject* /*args*/)
363{

Callers 1

testFilterMethod · 0.80

Calls 9

addMaterialsFunction · 0.85
setIncludeFavoritesMethod · 0.45
setIncludeRecentMethod · 0.45
setIncludeLegacyMethod · 0.45
getMaterialTreeMethod · 0.45
sizeMethod · 0.45

Tested by 1

testFilterMethod · 0.64