We work on a large number of projects and the file structure is normally the same so repeatedly browsing for the right location to save plans has issues. I would like to be able to change the default paths for saving layouts to PDFs, SVGs and images based on the project file path.
Following Changing default folder for saving layers in QGIS I can change the default path for saving vector layers by running the following code in the project macros.
import os
from qgis.core import QgsProject
from PyQt5.QtCore import QSettings
prjhomepath = QgsProject.instance().homePath()
if os.path.exists(prjhomepath):
QSettings().setValue('/UI/lastVectorFileFilterDir', prjhomepath)
I assumed there might be a setting for file saving similar to '/UI/lastVectorFileFilterDir' but the layout export directory seems to be a property of the project.
Saving the project file as a .qgs and examining the text file reveals a line that seems to be what I need.
If I change that text string (in Notepad) it successfully changes the default file path for exporting layouts.
How can I change that string with PyQGIS?