From 16c08ec96fd54547de340b3f703394dcc48c7038 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 27 Oct 2021 10:59:34 +0200 Subject: [PATCH] Base: [skip ci] in Rotation class allow to set angle in radian App.Rotation(axis, angle) still defines the angle in degree App.Rotation(axis, Degree=angle) does the same as above App.Rotation(axis, Radian=angle) defines the angle in radian --- src/Base/RotationPyImp.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Base/RotationPyImp.cpp b/src/Base/RotationPyImp.cpp index 1449f5ebe4..f62c745681 100644 --- a/src/Base/RotationPyImp.cpp +++ b/src/Base/RotationPyImp.cpp @@ -60,7 +60,7 @@ PyObject *RotationPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // P } // constructor method -int RotationPy::PyInit(PyObject* args, PyObject* /*kwd*/) +int RotationPy::PyInit(PyObject* args, PyObject* kwds) { PyObject* o; if (PyArg_ParseTuple(args, "")) { @@ -76,10 +76,18 @@ int RotationPy::PyInit(PyObject* args, PyObject* /*kwd*/) PyErr_Clear(); double angle; - if (PyArg_ParseTuple(args, "O!d", &(Base::VectorPy::Type), &o, &angle)) { - // NOTE: The last parameter defines the rotation angle in degree. - getRotationPtr()->setValue(static_cast(o)->value(), Base::toRadians(angle)); - return 0; + static char *kw_deg[] = {"Axis", "Degree", nullptr}; + if (PyArg_ParseTupleAndKeywords(args, kwds, "O!d", kw_deg, &(Base::VectorPy::Type), &o, &angle)) { + // NOTE: The last parameter defines the rotation angle in degree. + getRotationPtr()->setValue(static_cast(o)->value(), Base::toRadians(angle)); + return 0; + } + + PyErr_Clear(); + static char *kw_rad[] = {"Axis", "Radian", nullptr}; + if (PyArg_ParseTupleAndKeywords(args, kwds, "O!d", kw_rad, &(Base::VectorPy::Type), &o, &angle)) { + getRotationPtr()->setValue(static_cast(o)->value(), angle); + return 0; } PyErr_Clear();