QgsProcessingAlgorithm / add Layer to project #29492
Labels
Bug
Either a bug report, or a bug fix. Let's hope for the latter!
Processing
Relating to QGIS Processing framework or individual Processing algorithms
Author Name: Valérian LEBERT (Valérian LEBERT)
Original Redmine Issue: 21676
Affected QGIS version: 3.4.5
Redmine category:processing/core
Hi,
I am trying to add a layer to project in a QgsProcessingAlgorithm.
I tried the folowing code :
vlayer1 = QgsVectorLayer('Point?crs=epsg:4326&field=id:integer&field=name:string(20)&index=yes', 'vlayer1', "memory")
vlayer2 = QgsVectorLayer('Point?crs=epsg:4326&field=id:integer&field=name:string(20)&index=yes', 'vlayer2', "memory")
vlayer3 = QgsVectorLayer('Point?crs=epsg:4326&field=id:integer&field=name:string(20)&index=yes', 'vlayer3', "memory")
vlayer4 = QgsVectorLayer('Point?crs=epsg:4326&field=id:integer&field=name:string(20)&index=yes', 'vlayer4', "memory")
context.addLayerToLoadOnCompletion(vlayer1.id(),context.LayerDetails('toto', QgsProject.instance(), self.OUTPUT))
context.addLayerToLoadOnCompletion(vlayer2.id(),context.LayerDetails('toto', context.project(), self.OUTPUT))
QgsProject.instance().addMapLayer(vlayer3, True)
context.project().addMapLayer(vlayer4, True)
None of the layer is loaded.
OUTPUT variable is a string :
OUTPUT = 'OUTPUT'
I get a warning on processing feedback with no details in message log :
Chargement des couches de résultat
Les couches suivantes n'ont pas été générées correctement.
- vlayer1_98306459_f1bc_4285_b8dc_660502e5cb47
- vlayer2_040a7ea0_7a5f_4e02_bfd1_4ce311c60219
Vous pouvez vérifier le Panel de messages du journal dans la fenêtre principale de QGIS pour trouver plus d'informations à propos de l'exécution de l'algorithme.Am i doing wrong or is there something broken in procesing API?
Thanks
Valérian
The text was updated successfully, but these errors were encountered: