From 81e983b6ac925b5beb2a57a99711b745aa333bb5 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Tue, 5 Aug 2014 19:28:36 -0300 Subject: [PATCH] Exposed doCommand (Gui version) to python - fixes #1564 --- src/Gui/Application.h | 1 + src/Gui/ApplicationPy.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/Gui/Application.h b/src/Gui/Application.h index 8d4aefe5a..5458f340b 100644 --- a/src/Gui/Application.h +++ b/src/Gui/Application.h @@ -234,6 +234,7 @@ public: PYFUNCDEF_S(sGetDocument); PYFUNCDEF_S(sDoCommand); + PYFUNCDEF_S(sDoCommandGui); PYFUNCDEF_S(sAddModule); static PyMethodDef Methods[]; diff --git a/src/Gui/ApplicationPy.cpp b/src/Gui/ApplicationPy.cpp index 169a8e6f9..65cd2c6ea 100644 --- a/src/Gui/ApplicationPy.cpp +++ b/src/Gui/ApplicationPy.cpp @@ -136,6 +136,9 @@ PyMethodDef Application::Methods[] = { {"doCommand", (PyCFunction) Application::sDoCommand, 1, "doCommand(string) -> None\n\n" "Prints the given string in the python console and runs it"}, + {"doCommandGui", (PyCFunction) Application::sDoCommandGui, 1, + "doCommandGui(string) -> None\n\n" + "Prints the given string in the python console and runs it but doesn't record it in macros"}, {"addModule", (PyCFunction) Application::sAddModule, 1, "addModule(string) -> None\n\n" "Prints the given module import only once in the macro recording"}, @@ -845,6 +848,15 @@ PyObject* Application::sDoCommand(PyObject * /*self*/, PyObject *args,PyObject * return Py_None; } +PyObject* Application::sDoCommandGui(PyObject * /*self*/, PyObject *args,PyObject * /*kwd*/) +{ + char *pstr=0; + if (!PyArg_ParseTuple(args, "s", &pstr)) // convert args: Python->C + return NULL; // NULL triggers exception + Command::doCommand(Command::Gui,pstr); + return Py_None; +} + PyObject* Application::sAddModule(PyObject * /*self*/, PyObject *args,PyObject * /*kwd*/) { char *pstr=0;