EDIT
Answering the Someone191's comment.
Unfortunately this is where I came up with my questions Here and Here.
I couldn't create a simple process to solve the case directly in the script I'm working on.
The not-so-good solution I found was to create a second script that just gets an input and creates an identical output. Going back to the main script, I put this second basic script as the last step, so the name of the outputs will obey those that were defined in the second script.
The backing script, named InOut, basically has this:
def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterVectorLayer('Atlas','Atlas',optional=True, types=[QgsProcessing.TypeVector], defaultValue=None))
self.addParameter(QgsProcessingParameterFeatureSink('Atlas S','Atlas', type=QgsProcessing.TypeVectorAnyGeometry, createByDefault=True, defaultValue=None))
def processAlgorithm(self, parameters, context, feedback):
source = self.parameterAsSource(parameters,'Atlas',context)
(sink, dest_id) = self.parameterAsSink(parameters,'Atlas S',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):
sink.addFeature(feature, QgsFeatureSink.FastInsert)
feedback.setProgress(int(current * total))
return {'Output':('Renamed Shapes')}
The main script is like this:
def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterFeatureSink('AtlasOutput', 'ATLAS for Maps', type=QgsProcessing.TypeVectorAnyGeometry, createByDefault=True, defaultValue=None))
.
.
.
def processAlgorithm(self, parameters, context, model_feedback):
.
.
.
# Diferrence
alg_params = {
'INPUT': outputs['P29TalhesFinal']['OUTPUT'],
'OVERLAY': outputs['BufferGG']['OUTPUT'],
'OUTPUT': 'memory:'
}
outputs['2Diferena'] = processing.run('native:difference', alg_params, context=context, feedback=feedback, is_child_algorithm=True)
# InOut
alg_params = {
'Atlas': outputs['2Diferena']['OUTPUT'],
'Atlas S': parameters['AtlasOutput'],
}
outputs['Inout'] = processing.run('script:InOut', alg_params, context=context, feedback=feedback, is_child_algorithm=True)
return results
return {}
Note that the output will be named Atlas and not ATLAS for Maps, obeying the name given in the InOut script.
For now that's enough for me, but I'm still trying to solve it with just one script Here, let me know if you can make any progress with it.