On my way to find a solution to This Question, I´m trying to merge some automatic generated script with This example.

My thought is that after the last step, I could insert the script that does nothing with the file but only rename the output temporary file, because it´s not a native source.

Running everything in the toolbox.

How can I set the temporary output as an input to the example script?

This is the part of the automatic generated script:


    def initAlgorithm(self, config=None):
        self.addParameter(QgsProcessingParameterVectorLayer('maininput', 'Main Input', types=[QgsProcessing.TypeVector], defaultValue=None))
        self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT,self.tr('My output layer')))

        # Buffer
        alg_params = {
            'DISSOLVE': False,
            'DISTANCE': 10,
            'END_CAP_STYLE': 0,
            'INPUT': parameters['maininput'],
            'JOIN_STYLE': 0,
            'MITER_LIMIT': 2,
            'SEGMENTS': 5,
            'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT
        outputs['Buffer'] = processing.run('native:buffer', alg_params, context=context, feedback=feedback, is_child_algorithm=True)

and after that, I want to insert the other script, having "outputs['Buffer']['OUTPUT']" instead of "INPUT"

        source = self.parameterAsSource(parameters, outputs['Buffer']['OUTPUT'], context)

        (sink, dest_id) = self.parameterAsSink(
            parameters, "OUTPUT", context,
        source.fields(), source.wkbType(), source.sourceCrs())

        total = 100.0 / source.featureCount() if source.featureCount() else 0
        features = source.getFeatures()
        for current, feature in enumerate(features):
            if feedback.isCanceled():
            out_feature = QgsFeature(feature)
            sink.addFeature(out_feature, QgsFeatureSink.FastInsert)
            feedback.setProgress(int(current * total))

        return {"OUTPUT": dest_id}

I got an error

AttributeError: 'NoneType' object has no attribute 'fields'

1 Answer 1


As a partial solution I saved the template script with the desired output name and put it as the last step of my main script.

So I did not join parts of scripts, but whole scripts. However, the result was as expected, the output file is displayed with the name I assigned.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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