Hi André, Is it possible to refer to a list of layers in the project, or does 
your code run without the QGIS project being opened?Because, theoretically, you 
need to point the layer or feature class you will use to extract the selected 
items, and in this case, you can save the name in a separate variable to use 
lately  to create a name for the output.
I hope I helped.
José Roberto Ribeiro Filho - Geógrafo
    Em terça-feira, 3 de dezembro de 2024 às 13:24:42 BRT, Andre Kotze via 
QGIS-User <qgis-user@lists.osgeo.org> escreveu:  
 
 
Dear all,

I have a processing algorithm that names its output based on the input layer's 
name, e.g. if buffering a layer called 'powerlines_110kW' with 40m the output 
layer would be called 'powerlines_110kW+40m'. For the input I use 
QgsProcessingParameterFeatureSource (instead of VectorLayer), so that the 
"Selected features only" option is available.

My problem is, when "Selected features" is unchecked, I can get the input 
layer's name with the 'parameterAsVectorLayer(parameters, 'INPUT', 
context).name()' method. However, when "Selected features" is checked, 
'parameterAsVectorLayer()' returns None. This makes sense, as I believe the 
input becomes wrapped in a QgsProcessingFeatureSourceDefinition. Is there any 
way to get the layer's name before the selected features are extracted/filtered 
from the selected vector layer (the one given by the user in the ComboBox)?

Many thanks
André
_______________________________________________
QGIS-User mailing list
QGIS-User@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
  
_______________________________________________
QGIS-User mailing list
QGIS-User@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to