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

Function parseLink

src/App/LinkBaseExtensionPyImp.cpp:213–243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

211}
212
213void parseLink(LinkBaseExtension* ext, int index, PyObject* value)
214{
215 App::DocumentObject* obj = nullptr;
216 PropertyStringList subs;
217 PropertyString sub;
218 if (value != Py_None) {
219 if (PyObject_TypeCheck(value, &DocumentObjectPy::Type)) {
220 obj = static_cast<DocumentObjectPy*>(value)->getDocumentObjectPtr();
221 }
222 else if (!PySequence_Check(value)) {
223 throw Base::TypeError("Expects type of DocumentObject or sequence");
224 }
225 else {
226 Py::Sequence seq(value);
227 if (seq[0].ptr() != Py_None) {
228 if (!PyObject_TypeCheck(seq[0].ptr(), &DocumentObjectPy::Type)) {
229 throw Base::TypeError(
230 "Expects the first argument to be DocumentObject in sequence");
231 }
232 obj = static_cast<DocumentObjectPy*>(seq[0].ptr())->getDocumentObjectPtr();
233 if (seq.size() > 1) {
234 sub.setPyObject(seq[1].ptr());
235 if (seq.size() > 2) {
236 subs.setPyObject(seq[2].ptr());
237 }
238 }
239 }
240 }
241 }
242 ext->setLink(index, obj, sub.getValue(), subs.getValue());
243}
244
245PyObject* LinkBaseExtensionPy::setLink(PyObject* _args)
246{

Callers 1

setLinkMethod · 0.85

Calls 5

ptrMethod · 0.45
sizeMethod · 0.45
setPyObjectMethod · 0.45
setLinkMethod · 0.45
getValueMethod · 0.45

Tested by

no test coverage detected