I have the same Question as asked in this post (How to connect input parameter to the field calculator algorithm within the graphical modeler?) and the answer from Joseph already helped a lot:
##Update field by number=name ##Layer=vector ##Fields=Field Layer ##Number=number 0 from qgis.core import QgsExpression layer = processing.getObject(Layer) layer.startEditing() num = str(Number) idx = layer.fieldNameIndex(Fields) e = QgsExpression(num + '* 5') # Change value to suit your needs e.prepare(layer.pendingFields()) for f in layer.getFeatures(): f[idx] = e.evaluate(f) layer.updateFeature(f) layer.commitChanges()
Anyway, I'm looking for a way to multiply the number that the user enters in the interface with the value of the chosen field. In the script provided in the answer, the field value is ignored and the user value gets multiplied with the number defined in the script (default 5).
I have to admit that I'm not that much of a python programmer, so any suggestion would be very helpful.