[QGIS-Developer] Processing Script addLayerToLoadOnCompletion

matteo matteo.ghetta at gmail.com
Mon Sep 3 07:52:19 PDT 2018


Hi all,

I was thinking to add a small example of addLayerToLoadOnCompletion
function to the ScriptTemplate of Processing. The code is the following:

    buffered_layer = processing.run("native:buffer", parameters={
        'INPUT': dest_id,
        'DISTANCE': 10000,
        'SEGMENTS': 5,
        'END_CAP_STYLE': 0,
        'JOIN_STYLE': 0,
        'MITER_LIMIT': 2,
        'DISSOLVE': False,
        'OUTPUT': 'memory:'
    }, context=context, feedback=feedback)['OUTPUT']

    feedback.pushDebugInfo(str(dest_id))

    context.addLayerToLoadOnCompletion(buffered_layer.source(),
context.LayerDetails(
        name='new_layer',
        project=context.project()
    ))

but Processing always throws this error:

The following layers were not correctly
generated.<ul><li>Polygon?crs=EPSG:3003&field=ID:long(10)&field=fk:string(254)&field=ROTAZ:long(10)&field=DIMENS:long(10)&field=ETICHETTA:string(254)&field=VALORE:long(10)&field=T_MIN:double(20,5)&field=T_MAX:double(20,5)&field=PIOGGIA:double(20,5)&field=LARGH:double(20,5)&field=LUNG:double(20,5)&field=assex:string(254)&field=assey:string(254)&field=colore:string(38)&field=xlab:double(10,2)&field=ylab:double(10,2)&field=raster:double(23,15)&field=raster_1:double(23,15)&field=raster_2:double(23,15)&uid={685540af-711d-462b-a9d0-9b00af4c2f6a}</li></ul>You
can check the 'Log Messages Panel' in QGIS main window to find more
information about the execution of the algorithm.


Am I missing something?

Thanks for any suggestion

Matteo





More information about the QGIS-Developer mailing list