From 87342ec6685117c30a1cba11cbebb6cc96d7b6b9 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Sat, 19 Jun 2021 08:56:08 +0200 Subject: [PATCH] Sketcher: Python wrappers for new remove axes alignment algorithm --- src/Mod/Sketcher/App/SketchObjectPy.xml | 5 ++++ src/Mod/Sketcher/App/SketchObjectPyImp.cpp | 29 ++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/Mod/Sketcher/App/SketchObjectPy.xml b/src/Mod/Sketcher/App/SketchObjectPy.xml index 20f993e6a4..e0fc4ef408 100644 --- a/src/Mod/Sketcher/App/SketchObjectPy.xml +++ b/src/Mod/Sketcher/App/SketchObjectPy.xml @@ -242,6 +242,11 @@ If there is no such constraint an exception is raised. add an array of size cols by rows where each element is a copy of the selected geometric objects displaced by a vector3d in the cols direction and by a vector perpendicular to it in the rows direction + + + modifies constraints so that the shape is not forced to be aligned with axes. + + Deprecated -- use exposeInternalGeometry diff --git a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp index 7f9d330a40..2def994844 100644 --- a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp +++ b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp @@ -1293,6 +1293,35 @@ PyObject* SketchObjectPy::addRectangularArray(PyObject *args) throw Py::TypeError(error); } +PyObject* SketchObjectPy::removeAxesAlignment(PyObject *args) +{ + PyObject *pcObj; + + if (!PyArg_ParseTuple(args, "O", &pcObj)) + return 0; + + if (PyObject_TypeCheck(pcObj, &(PyList_Type)) || + PyObject_TypeCheck(pcObj, &(PyTuple_Type))) { + std::vector geoIdList; + Py::Sequence list(pcObj); + for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) { + if (PyLong_Check((*it).ptr())) + geoIdList.push_back(PyLong_AsLong((*it).ptr())); + } + + int ret = this->getSketchObjectPtr()->removeAxesAlignment(geoIdList) + 1; + + if(ret == -1) + throw Py::TypeError("Operation unsuccessful!"); + + Py_Return; + } + + std::string error = std::string("type must be list of GeoIds, not "); + error += pcObj->ob_type->tp_name; + throw Py::TypeError(error); +} + PyObject* SketchObjectPy::calculateAngleViaPoint(PyObject *args) { int GeoId1=0, GeoId2=0;