diff --git a/src/Mod/Sketcher/App/SketchObjectPy.xml b/src/Mod/Sketcher/App/SketchObjectPy.xml index d9d5834b9b..43dab8c3b7 100644 --- a/src/Mod/Sketcher/App/SketchObjectPy.xml +++ b/src/Mod/Sketcher/App/SketchObjectPy.xml @@ -253,7 +253,7 @@ carbonCopy(objName:str, asConstruction=True) Add a link to an external geometry. -addExternal(objName:str, subName:str, bool:defining, bool:intersection) +addExternal(objName:str, subName:str, defining:bool=False, intersection:bool=False) Args: objName: The name of the document object to reference. diff --git a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp index 072e389e66..6887c95a6f 100644 --- a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp +++ b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp @@ -555,39 +555,24 @@ PyObject* SketchObjectPy::carbonCopy(PyObject* args) PyObject* SketchObjectPy::addExternal(PyObject* args) { - char* ObjectName; - char* SubName; - PyObject* defining; // this is an optional argument default false - PyObject* intersection; // this is an optional argument default false - bool isDefining; - bool isIntersection; + char* ObjectName = nullptr; + char* SubName = nullptr; + PyObject* defining = Py_False; + PyObject* intersection = Py_False; if (!PyArg_ParseTuple(args, - "ssO!O!", + "ss|O!O!", &ObjectName, &SubName, &PyBool_Type, &defining, &PyBool_Type, &intersection)) { - if (!PyArg_ParseTuple(args, "ssO!", &ObjectName, &SubName, &PyBool_Type, &defining)) { - PyErr_Clear(); - if (!PyArg_ParseTuple(args, "ss", &ObjectName, &SubName)) { - return nullptr; - } - else { - isDefining = false; - } - } - else { - isDefining = Base::asBoolean(defining); - } - isIntersection = false; - } - else { - isDefining = Base::asBoolean(defining); - isIntersection = Base::asBoolean(intersection); + return nullptr; } + bool isDefining = Base::asBoolean(defining); + bool isIntersection = Base::asBoolean(intersection); + // get the target object for the external link Sketcher::SketchObject* skObj = this->getSketchObjectPtr(); App::DocumentObject* Obj = skObj->getDocument()->getObject(ObjectName);