diff --git a/src/Gui/View3DPy.cpp b/src/Gui/View3DPy.cpp index 1114e15b5b..48c2bdc881 100644 --- a/src/Gui/View3DPy.cpp +++ b/src/Gui/View3DPy.cpp @@ -127,6 +127,9 @@ void View3DInventorPy::init_type() add_varargs_method("getViewDirection",&View3DInventorPy::getViewDirection,"getViewDirection() --> tuple of floats\n" "returns the direction vector the view is currently pointing at as tuple with xyz values\n" ); + add_varargs_method("getUpDirection",&View3DInventorPy::getUpDirection,"getUpDirection() --> tuple of integers\n" + "Returns the up direction vector\n" + ); add_varargs_method("setViewDirection",&View3DInventorPy::setViewDirection,"setViewDirection(tuple) --> None\n" "Sets the direction the view is pointing at. The direction must be given as tuple with\n" "three coordinates xyz" @@ -1042,6 +1045,26 @@ Py::Object View3DInventorPy::getViewDirection(const Py::Tuple& args) } } + +Py::Object View3DInventorPy::getUpDirection(const Py::Tuple& args) +{ + if (!PyArg_ParseTuple(args.ptr(), "")) + throw Py::Exception(); + try { + SbVec3f dvec = getView3DIventorPtr()->getViewer()->getUpDirection(); + return Py::Vector(Base::Vector3f(dvec[0], dvec[1], dvec[2])); + } + catch (const Base::Exception& e) { + throw Py::RuntimeError(e.what()); + } + catch (const std::exception& e) { + throw Py::RuntimeError(e.what()); + } + catch (...) { + throw Py::RuntimeError("Unknown C++ exception"); + } +} + Py::Object View3DInventorPy::setViewDirection(const Py::Tuple& args) { PyObject* object; diff --git a/src/Gui/View3DPy.h b/src/Gui/View3DPy.h index c69759845c..a6211fe351 100644 --- a/src/Gui/View3DPy.h +++ b/src/Gui/View3DPy.h @@ -82,6 +82,7 @@ public: Py::Object saveVectorGraphic(const Py::Tuple&); Py::Object getCamera(const Py::Tuple&); Py::Object getViewDirection(const Py::Tuple&); + Py::Object getUpDirection(const Py::Tuple&); Py::Object setViewDirection(const Py::Tuple&); Py::Object setCamera(const Py::Tuple&); Py::Object setCameraOrientation(const Py::Tuple&);