diff --git a/src/App/Application.h b/src/App/Application.h index b966d43ae0..e4758ee524 100644 --- a/src/App/Application.h +++ b/src/App/Application.h @@ -306,6 +306,7 @@ private: static PyObject* sGetExportType (PyObject *self,PyObject *args,PyObject *kwd); static PyObject* sGetResourceDir (PyObject *self,PyObject *args,PyObject *kwd); static PyObject* sGetUserAppDataDir (PyObject *self,PyObject *args,PyObject *kwd); + static PyObject* sGetUserMacroDir (PyObject *self,PyObject *args,PyObject *kwd); static PyObject* sGetHomePath (PyObject *self,PyObject *args,PyObject *kwd); static PyObject* sLoadFile (PyObject *self,PyObject *args,PyObject *kwd); diff --git a/src/App/ApplicationPy.cpp b/src/App/ApplicationPy.cpp index 16f1a27ec1..f2d170e92c 100644 --- a/src/App/ApplicationPy.cpp +++ b/src/App/ApplicationPy.cpp @@ -85,6 +85,8 @@ PyMethodDef Application::Methods[] = { "Get the root directory of all resources"}, {"getUserAppDataDir", (PyCFunction) Application::sGetUserAppDataDir ,1, "Get the root directory of user settings"}, + {"getUserMacroDir", (PyCFunction) Application::sGetUserMacroDir ,1, + "Get the directory of the user's macro directory"}, {"getHomePath", (PyCFunction) Application::sGetHomePath ,1, "Get the home path, i.e. the parent directory of the executable"}, @@ -582,6 +584,15 @@ PyObject* Application::sGetUserAppDataDir(PyObject * /*self*/, PyObject *args,Py return Py::new_reference_to(user_data_dir); } +PyObject* Application::sGetUserMacroDir(PyObject * /*self*/, PyObject *args,PyObject * /*kwd*/) +{ + if (!PyArg_ParseTuple(args, "")) // convert args: Python->C + return NULL; // NULL triggers exception + + Py::String user_macro_dir(Application::getUserMacroDir(),"utf-8"); + return Py::new_reference_to(user_macro_dir); +} + PyObject* Application::sGetHomePath(PyObject * /*self*/, PyObject *args,PyObject * /*kwd*/) { if (!PyArg_ParseTuple(args, "")) // convert args: Python->C diff --git a/src/Mod/Path/PathScripts/PathPreferences.py b/src/Mod/Path/PathScripts/PathPreferences.py index 4e4d9c28b1..f5e025913d 100644 --- a/src/Mod/Path/PathScripts/PathPreferences.py +++ b/src/Mod/Path/PathScripts/PathPreferences.py @@ -112,7 +112,7 @@ class PathPreferences: @classmethod def macroFilePath(cls): grp = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro") - return grp.GetString("MacroPath", FreeCAD.getUserAppDataDir()) + return grp.GetString("MacroPath", FreeCAD.getUserMacroDir()) @classmethod def searchPaths(cls):