Added FreeCADGui.doCommand() python command
This commit is contained in:
parent
ef24e4d2e6
commit
4f91a5a71b
|
@ -231,6 +231,8 @@ public:
|
|||
PYFUNCDEF_S(sActiveDocument);
|
||||
PYFUNCDEF_S(sGetDocument);
|
||||
|
||||
PYFUNCDEF_S(sDoCommand);
|
||||
|
||||
static PyMethodDef Methods[];
|
||||
|
||||
private:
|
||||
|
|
|
@ -128,6 +128,9 @@ PyMethodDef Application::Methods[] = {
|
|||
{"getDocument", (PyCFunction) Application::sGetDocument, 1,
|
||||
"getDocument(string) -> object\n\n"
|
||||
"Get a document by its name"},
|
||||
{"doCommand", (PyCFunction) Application::sDoCommand, 1,
|
||||
"doCommand(string) -> None\n\n"
|
||||
"Prints the given string in the python console and runs it"},
|
||||
|
||||
{NULL, NULL} /* Sentinel */
|
||||
};
|
||||
|
@ -765,3 +768,12 @@ PyObject* Application::sRunCommand(PyObject * /*self*/, PyObject *args,PyObject
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
PyObject* Application::sDoCommand(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::Doc,pstr);
|
||||
return Py_None;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user