diff --git a/src/App/DocumentObjectPy.xml b/src/App/DocumentObjectPy.xml index 50633d38bb..288f351214 100644 --- a/src/App/DocumentObjectPy.xml +++ b/src/App/DocumentObjectPy.xml @@ -55,6 +55,11 @@ Register an expression for a property + + + Evaluate an expression + + recompute(recursive=False): Recomputes this object diff --git a/src/App/DocumentObjectPyImp.cpp b/src/App/DocumentObjectPyImp.cpp index 182d6bc520..5da0b636d7 100644 --- a/src/App/DocumentObjectPyImp.cpp +++ b/src/App/DocumentObjectPyImp.cpp @@ -368,6 +368,20 @@ PyObject* DocumentObjectPy::setExpression(PyObject * args) Py_Return; } +PyObject* DocumentObjectPy::evalExpression(PyObject * args) +{ + const char *expr; + if (!PyArg_ParseTuple(args, "s", &expr)) // convert args: Python->C + return NULL; // NULL triggers exception + + PY_TRY { + boost::shared_ptr shared_expr(Expression::parse(getDocumentObjectPtr(), expr)); + if(shared_expr) + return Py::new_reference_to(shared_expr->getPyValue()); + Py_Return; + } PY_CATCH +} + PyObject* DocumentObjectPy::recompute(PyObject *args) { PyObject *recursive=Py_False;