How do I export my model from Processing Modeler as .py
so that I can edit its code?
This does not seem as intuitive as in previous QGIS versions.
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.
Sign up to join this communityHow do I export my model from Processing Modeler as .py
so that I can edit its code?
This does not seem as intuitive as in previous QGIS versions.
Early versions of QGIS 3 did not support exporting models to scripts (See: Why "Export as Python script" button is unaccessible in QGIS 3.0/3.1 Modeler by default?)
From QGIS 3.6, the export to script button is back and creates a proper QGIS3 Processing script:
You can make it accessible.
Find "DlgModeler.ui"
and "ModelerDialog.py"
files in QGIS folder. (That folder depends on which way you installed it).
By default (in Windows):"DlgModeler.ui"
is located in "QGIS_PATH/python/plugins/processing/ui/""ModelerDialog.py"
is located in "QGIS_PATH/python/plugins/processing/modeler/"
additionally you may check this folder "C:/.../QGIS/apps/qgis-ltr/python/plugins/processing"
Open "DlgModeler.ui"
in editor (maybe Notepad), find "addaction" tags.
Add "<addaction name="mActionExportPython"/>
and Save.
Open "ModelerDialog.py"
in editor and uncomment the lines below and Save it.
#self.mActionExportPython.setIcon(
# QgsApplication.getThemeIcon('/mActionSaveAsPython.svg'))
...
#self.mActionExportPython.triggered.connect(self.exportAsPython)
Open QGIS 3.0
EDITS