-1

I'm getting this error when I try to run the following code:

a6 = processing.run("native:difference", {'INPUT':'_78b00e45_4a8e_4490_9920_f75f6e055a6a','OVERLAY':'te_afb4845c_d9b4_4498_87b0_9da89a98b2f4','OUTPUT':'TEMPORARY_OUTPUT'})
layer1 = QgsVectorLayer(a6['OUTPUT'])
QgsProject.instance().addMapLayer(layer1)

How can I solve it?

3

Try this:

a6 = processing.run("native:difference", {'INPUT':'_78b00e45_4a8e_4490_9920_f75f6e055a6a','OVERLAY':'te_afb4845c_d9b4_4498_87b0_9da89a98b2f4','OUTPUT':'TEMPORARY_OUTPUT'})
layer1 = a6['OUTPUT']
QgsProject.instance().addMapLayer(layer1)

processing.run returns a dictionary structured as {"OUTPUT": <QgsVectorLayer instance>}. a6["OUTPUT"] is already a QgsVectorLayer.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.