diff --git a/src/Base/PlacementPy.xml b/src/Base/PlacementPy.xml
index 3ccb012a32..9a78c23671 100644
--- a/src/Base/PlacementPy.xml
+++ b/src/Base/PlacementPy.xml
@@ -75,6 +75,14 @@ Placement(Base, Axis, Angle) -- define position and rotation
+
+
+
+ isNull() -> Bool
+ returns True if the placement has no displacement and no rotation
+
+
+
Vector to the Base Position of the Placement
diff --git a/src/Base/PlacementPyImp.cpp b/src/Base/PlacementPyImp.cpp
index 7e1dece97c..6a3f7956e9 100644
--- a/src/Base/PlacementPyImp.cpp
+++ b/src/Base/PlacementPyImp.cpp
@@ -83,9 +83,9 @@ int PlacementPy::PyInit(PyObject* args, PyObject* /*kwd*/)
PyObject* d;
double angle;
if (PyArg_ParseTuple(args, "O!O!d", &(Base::VectorPy::Type), &o,
- &(Base::VectorPy::Type), &d, &angle)) {
- // NOTE: The first parameter defines the translation, the second the rotation axis
- // and the last parameter defines the rotation angle in degree.
+ &(Base::VectorPy::Type), &d, &angle)) {
+ // NOTE: The first parameter defines the translation, the second the rotation axis
+ // and the last parameter defines the rotation angle in degree.
Base::Rotation rot(static_cast(d)->value(), angle/180.0*D_PI);
*getPlacementPtr() = Base::Placement(static_cast(o)->value(),rot);
return 0;
@@ -145,13 +145,13 @@ PyObject* PlacementPy::multVec(PyObject * args)
getPlacementPtr()->multVec(pnt, pnt);
return new VectorPy(new Vector3d(pnt));
}
-
-PyObject* PlacementPy::copy(PyObject * args)
-{
- if (!PyArg_ParseTuple(args, ""))
- return NULL;
- return new PlacementPy(new Placement(*getPlacementPtr()));
-}
+
+PyObject* PlacementPy::copy(PyObject * args)
+{
+ if (!PyArg_ParseTuple(args, ""))
+ return NULL;
+ return new PlacementPy(new Placement(*getPlacementPtr()));
+}
PyObject* PlacementPy::toMatrix(PyObject * args)
{
@@ -169,6 +169,19 @@ PyObject* PlacementPy::inverse(PyObject * args)
return new PlacementPy(new Placement(p));
}
+PyObject* PlacementPy::isNull(PyObject *args)
+{
+ if (!PyArg_ParseTuple(args, ""))
+ return NULL;
+ Base::Vector3d pos = getPlacementPtr()->getPosition();
+ Base::Rotation rot = getPlacementPtr()->getRotation();
+ Base::Vector3d nullvec(0,0,0);
+ Base::Rotation nullrot(0,0,0,1);
+ Base::Rotation nullrotinv(0,0,0,-1);
+ bool null = (pos == nullvec) & ((rot == nullrot) | (rot == nullrotinv));
+ return Py_BuildValue("O", (null ? Py_True : Py_False));
+}
+
Py::Object PlacementPy::getBase(void) const
{
return Py::Vector(getPlacementPtr()->getPosition());