1

I am trying to update a project variable using the graphical modeller. I am using the set project variable algorithm which runs fine but the behaviour is not as expected. Rather than updating the value of the existing variable the algorithm creates a variable using the value from the old variable and sets that new variables value to the new value. I have searched for similar issues and found This Post and I can run the command in the python console and it works fine but I need to do the rest of the processing in the Graphical Modeller

QgsExpressionContextUtils.setProjectVariable(QgsProject.instance(), 'myvar','hello world')
Sethinacan
  • 1,724
  • 11
  • 19

1 Answers1

0

Late, but what you can do:

  1. create a script that does what you want by running the python code
  2. add the script to your model in the graphical modeler
Fee
  • 1,158
  • 4
  • 14
  • 2
    I got it working using the set project variable algorithm. I don't think adding a script to a model is very simple - is there an easy way to do it? – Sethinacan Nov 12 '22 at 20:18