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

Method modelFromObject

src/Mod/Material/App/ExternalManager.cpp:690–714  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

688}
689
690std::shared_ptr<Model> ExternalManager::modelFromObject(const Py::Object& entry,
691 const QString& uuid)
692{
693 if (!checkModelObjectType(entry)) {
694 throw InvalidModel();
695 }
696
697 Py::String pyName(entry.getAttr("libraryName"));
698 Py::Object modelObject(entry.getAttr("model"));
699
700 QString libraryName;
701 if (!pyName.isNone()) {
702 libraryName = QString::fromStdString(pyName.as_string());
703 }
704
705 // Using this call will use caching, whereas using our class function will not
706 auto library = ModelManager::getManager().getLibrary(libraryName);
707
708 Model* model = static_cast<ModelPy*>(*modelObject)->getModelPtr();
709 model->setUUID(uuid);
710 model->setLibrary(library);
711 auto shared = std::make_shared<Model>(*model);
712
713 return shared;
714}
715
716std::shared_ptr<Model> ExternalManager::getModel(const QString& uuid)
717{

Callers

nothing calls this directly

Calls 6

InvalidModelClass · 0.85
isNoneMethod · 0.80
as_stringMethod · 0.45
getLibraryMethod · 0.45
getModelPtrMethod · 0.45
setUUIDMethod · 0.45

Tested by

no test coverage detected