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

Method createInstanceByName

src/Base/TypePyImp.cpp:228–250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

226}
227
228PyObject* TypePy::createInstanceByName(PyObject* args)
229{
230 const char* name {};
231 PyObject* load = Py_False; // NOLINT
232 if (!PyArg_ParseTuple(args, "s|O!", &name, &PyBool_Type, &load)) {
233 return nullptr;
234 }
235
236 bool loadModule = asBoolean(load);
237 Base::Type type = Type::getTypeIfDerivedFrom(name, BaseClass::getClassTypeId(), loadModule);
238 if (type.isBad()) {
239 Py_Return;
240 }
241
242 void* typeInstance = type.createInstance();
243 if (!typeInstance) {
244 Py_Return;
245 }
246
247 BaseClass* base = static_cast<BaseClass*>(typeInstance);
248
249 return createPyObject(base);
250}
251
252Py::String TypePy::getName() const
253{

Callers

nothing calls this directly

Calls 4

asBooleanFunction · 0.85
createPyObjectFunction · 0.85
isBadMethod · 0.45
createInstanceMethod · 0.45

Tested by

no test coverage detected