Added batch_number variable in algorithm scope to allow use it in the expression editor in Processing batch context

This commit is contained in:
Luigi Pirelli 2019-09-02 11:43:57 +02:00 committed by Nyall Dawson
parent 2001e0fcf5
commit a4b9ef73fd

View File

@ -217,6 +217,9 @@ class BatchPanelFillWidget(QToolButton):
for k, v in params.items():
alg_scope.setVariable(k, v, True)
# add batchCount in the alg scope to be used in the expressions. 0 is only an example value
alg_scope.setVariable('batch_number', 0, True)
expression_context.appendScope(alg_scope)
# mark the parameter variables as highlighted for discoverability
@ -253,6 +256,9 @@ class BatchPanelFillWidget(QToolButton):
for k, v in params.items():
alg_scope.setVariable(k, v, True)
# add batch row number as evaluable variable in algorithm scope
alg_scope.setVariable('batch_number', row, True)
expression_context.appendScope(alg_scope)
# rebuild a new expression every time -- we don't want the expression compiler to replace