diff --git a/src/Gui/Application.h b/src/Gui/Application.h index 44a73d0c6..bbbf0e923 100644 --- a/src/Gui/Application.h +++ b/src/Gui/Application.h @@ -232,6 +232,7 @@ public: PYFUNCDEF_S(sGetDocument); PYFUNCDEF_S(sDoCommand); + PYFUNCDEF_S(sAddModule); static PyMethodDef Methods[]; diff --git a/src/Gui/ApplicationPy.cpp b/src/Gui/ApplicationPy.cpp index a1e89811a..31df22271 100644 --- a/src/Gui/ApplicationPy.cpp +++ b/src/Gui/ApplicationPy.cpp @@ -131,6 +131,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"}, + {"addModule", (PyCFunction) Application::sAddModule, 1, + "addModule(string) -> None\n\n" + "Prints the given module import only once in the macro recording"}, {NULL, NULL} /* Sentinel */ }; @@ -795,3 +798,12 @@ PyObject* Application::sDoCommand(PyObject * /*self*/, PyObject *args,PyObject * Command::doCommand(Command::Doc,pstr); return Py_None; } + +PyObject* Application::sAddModule(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::addModule(Command::Doc,pstr); + return Py_None; +}