File tree Expand file tree Collapse file tree 1 file changed +20
-10
lines changed Expand file tree Collapse file tree 1 file changed +20
-10
lines changed Original file line number Diff line number Diff line change @@ -255,20 +255,30 @@ def runalg(name, *args):
255
255
return
256
256
257
257
alg = alg .getCopy ()#copy.deepcopy(alg)
258
- i = 0
259
- for param in alg .parameters :
260
- if not param .setValue (args [i ]):
261
- print ("Error: Wrong parameter value: " + args [i ])
258
+ if isinstance (args , dict ):
259
+ # set params by name
260
+ for name , value in args .items ():
261
+ if alg .getParameterFromName (name ).setValue (value ):
262
+ continue ;
263
+ if alg .getOutputFromName (name ).setValue (value ):
264
+ continue ;
265
+ print ("Error: Wrong parameter value %s for parameter %s." % (value , name ))
262
266
return
263
- i = i + 1
264
-
265
- for output in alg .outputs :
266
- if not output .hidden :
267
- if not output .setValue (args [i ]):
268
- print ("Error: Wrong output value: " + args [i ])
267
+ else :
268
+ i = 0
269
+ for param in alg .parameters :
270
+ if not param .setValue (args [i ]):
271
+ print ("Error: Wrong parameter value: " + args [i ])
269
272
return
270
273
i = i + 1
271
274
275
+ for output in alg .outputs :
276
+ if not output .hidden :
277
+ if not output .setValue (args [i ]):
278
+ print ("Error: Wrong output value: " + args [i ])
279
+ return
280
+ i = i + 1
281
+
272
282
msg = alg .checkParameterValuesBeforeExecuting ()
273
283
if msg :
274
284
print ("Unable to execute algorithm\n " + msg )
You can’t perform that action at this time.
0 commit comments